home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / c01lab4.zip / LRMRDR / LRM_CHAP.ZIP / CHAP03.DOC < prev    next >
Text File  |  1992-04-21  |  145KB  |  5,318 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. The following document is a draft  of  the  corresponding  chapter  of  the
  7. version  of  the  Ada  Reference  Manual  produced  in response to the Ansi
  8. Canvass.  It is given a limited circulation  to  Ada  implementers  and  to
  9. other groups contributing comments (according to the conventions defined in
  10. RRM.comments).  This draft should not be referred to in any publication.
  11.  
  12.  
  13.  
  14.                       ANSI-RM-03-v23 - Draft Chapter
  15.  
  16.                          3  Declarations and Types
  17.                                 version 23
  18.  
  19.                                  83-02-11
  20.  
  21. This version has addressed comments up to #5795
  22.  
  23. It has not yet considered the proposed amendment #3518
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. >                          3. Declarations and Types
  78.  
  79.  
  80.  
  81. This  chapter  describes  the  types  in  the  language  and  the rules for
  82. declaring constants, variables, and named numbers.
  83.  
  84.  
  85.  
  86. > 3.1  Declarations
  87.  
  88.  
  89. The language defines several kinds of entities that  are  declared,  either
  90. explicitly or implicitly, by declarations.  Such an entity can be a numeric
  91. literal,  an  object, a discriminant, a record component, a loop parameter,
  92. an exception, a type, a subtype, a subprogram, a package, a  task  unit,  a
  93. generic  unit,  a  single  entry, an entry family, a formal parameter (of a
  94. subprogram, entry, or generic subprogram), a generic  formal  parameter,  a
  95. named  block  or loop, a labeled statement, or an operation (in particular,
  96. an attribute or an enumeration literal;  see 3.3.3).
  97.  
  98. There are several forms of declaration.  A basic declaration is a  form  of
  99. declaration defined as follows.
  100.  
  101.     basic_declaration ::=
  102.          object_declaration     | number_declaration
  103.        | type_declaration       | subtype_declaration
  104.        | subprogram_declaration | package_declaration
  105.        | task_declaration       | generic_declaration
  106.        | exception_declaration  | generic_instantiation
  107.        | renaming_declaration   | deferred_constant_declaration
  108.  
  109. Certain  forms  of declaration always occur (explicitly) as part of a basic
  110. declaration;   these  forms  are  discriminant  specifications,   component
  111. declarations,   entry   declarations,   parameter  specifications,  generic
  112. parameter declarations, and enumeration  literal  specifications.   A  loop
  113. parameter  specification  is  a  form  of  declaration  that occurs only in
  114. certain forms of loop statement.
  115.  
  116. The remaining forms of declaration are implicit:  the name of a block,  the
  117. name  of  a  loop,  and a statement label are implicitly declared.  Certain
  118. operations are implicitly declared (see 3.3.3).
  119.  
  120. For each form of declaration the language rules define a certain region  of
  121. text  called  the  scope  of  the  declaration (see 8.2).  Several forms of
  122. declaration associate an identifier with a  declared  entity.   Within  its
  123. scope,  and  only  there,  there are places where it is possible to use the
  124. identifier to refer to the associated declared entity;   these  places  are
  125. defined  by  the visibility rules (see 8.3).  At such places the identifier
  126. is said to be a name of the entity (its simple name);  the name is said  to
  127. denote the associated entity.
  128.  
  129. Certain  forms  of  enumeration literal specification associate a character
  130. literal  with  the  corresponding  declared  entity.   Certain   forms   of
  131. declaration  associate  an  operator  symbol or some other notation with an
  132. explicitly or implicitly declared operation.
  133.  
  134. The process by which a  declaration  achieves  its  effect  is  called  the
  135. elaboration  of  the  declaration;   this  process  happens  during program
  136. execution.
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192. After its elaboration, a declaration is said to be  elaborated.   Prior  to
  193. the  completion  of its elaboration (including before the elaboration), the
  194. declaration is not yet elaborated.  The elaboration of any declaration  has
  195. always  at least the effect of achieving this change of state (from not yet
  196. elaborated to elaborated).   The  phrase  "the  elaboration  has  no  other
  197. effect"  is  used  in this manual whenever this change of state is the only
  198. effect of elaboration for some form of declaration.  An elaboration process
  199. is also defined for declarative parts, declarative items,  and  compilation
  200. units (see 3.9 and 10.5).
  201.  
  202. Object,  number,  type,  and  subtype declarations are described here.  The
  203. remaining basic declarations are described in later chapters.
  204.  
  205. Note:
  206.  
  207. The syntax rules use the term identifier for the  first  occurrence  of  an
  208. identifier  in  some form of declaration;  the term simple name is used for
  209. any occurrence of an identifier that already denotes some declared  entity.
  210.  
  211. References:    attribute  4.1.4,  block  name  5.6,  block  statement  5.6,
  212. character literal 2.5, component declaration  3.7,  declarative  item  3.9,
  213. declarative  part  3.9,  deferred  constant  declaration  7.4, discriminant
  214. specification 3.7.1, elaboration 3.9, entry  declaration  9.5,  enumeration
  215. literal   specification   3.5.1,   exception   declaration   11.1,  generic
  216. declaration 12.1, generic instantiation 12.3, generic parameter declaration
  217. 12.1,  identifier  2.3,  label  5.1,  loop   name   5.5,   loop   parameter
  218. specification  5.5, loop statement 5.5, name 4.1, number declaration 3.2.2,
  219. numeric literal 2.4, object  declaration  3.2.1,  operation  3.3,  operator
  220. symbol  6.1,  package  declaration 7.1, parameter specification 6.1, record
  221. component 3.7, renaming declaration 8.5, representation clause 13.1,  scope
  222. 8.2,  simple  name  4.1,  subprogram  body 6.3, subprogram declaration 6.1,
  223. subtype declaration 3.3.2, task declaration 9.1,  type  declaration  3.3.1,
  224. visibility 8.3
  225.  
  226.  
  227.  
  228. > 3.2  Objects and Named Numbers
  229.  
  230.  
  231. An  object  is  an  entity that contains (has) a value of a given type.  An
  232. object is one of the following:
  233.  
  234.   -  an object declared by an  object  declaration  or  by  a  single  task
  235.      declaration,
  236.  
  237.   -  a formal parameter of a subprogram, entry, or generic subprogram,
  238.  
  239.   -  a generic formal object,
  240.  
  241.   -  a loop parameter,
  242.  
  243.   -  an object designated by a value of an access type,
  244.  
  245.   -  a component or a slice of another object.
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257. A  number  declaration  is  a  special  form  of  object  declaration  that
  258. associates  an  identifier  with  a  value  of  type  universal_integer  or
  259. universal_real.
  260.  
  261.     object_declaration ::=
  262.          identifier_list : [constant] subtype_indication [:= expression];
  263.        | identifier_list : [constant] constrained_array_definition [:= expression];
  264.  
  265.     number_declaration ::=
  266.          identifier_list : constant := universal_static_expression;
  267.  
  268.     identifier_list ::=  identifier {, identifier}
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322. An  object  declaration  is  called  a  single  object  declaration  if its
  323. identifier list has a single identifier;  it is called  a  multiple  object
  324. declaration if the identifier list has two or more identifiers.  A multiple
  325. object  declaration is equivalent to a sequence of the corresponding number
  326. of single object declarations.   For  each  identifier  of  the  list,  the
  327. equivalent  sequence  has  a  single  object  declaration  formed  by  this
  328. identifier, followed by a colon and by whatever appears at the right of the
  329. colon in the multiple object declaration;  the equivalent  sequence  is  in
  330. the same order as the identifier list.
  331.  
  332. A  similar  equivalence  applies  also  for  the identifier lists of number
  333. declarations,   component   declarations,   discriminant    specifications,
  334. parameter   specifications,   generic   parameter  declarations,  exception
  335. declarations, and deferred constant declarations.
  336.  
  337. In the remainder of this  reference  manual,  explanations  are  given  for
  338. declarations  with a single identifier;  the corresponding explanations for
  339. declarations with several identifiers follow from  the  equivalence  stated
  340. above.
  341.  
  342. Example:
  343.  
  344.     --  the multiple object declaration
  345.  
  346.     JOHN, PAUL : PERSON_NAME := new PERSON(SEX => M);  --  see 3.8.1
  347.  
  348.     --  is equivalent to the two single object declarations in the order given
  349.  
  350.     JOHN : PERSON_NAME := new PERSON(SEX => M);
  351.     PAUL : PERSON_NAME := new PERSON(SEX => M);
  352.  
  353. References:   access  type 3.8, constrained array definition 3.6, component
  354. 3.3, declaration 3.1, deferred constant  declaration  7.4,  designate  3.8,
  355. discriminant  specification  3.7.1,  entry 9.5, exception declaration 11.1,
  356. expression 4.4, formal parameter 6.1, generic formal object 12.1.1, generic
  357. parameter declaration 12.1,  generic  unit  12,  generic  subprogram  12.1,
  358. identifier   2.3,   loop   parameter   5.5,  numeric  type  3.5,  parameter
  359. specification 6.1, scope 8.2, simple name 4.1, single task declaration 9.1,
  360. slice 4.1.2, static expression 4.9, subprogram 6, subtype indication 3.3.2,
  361. type 3.3, universal_integer type 3.5.4, universal_real type 3.5.6
  362.  
  363.  
  364.  
  365. > 3.2.1  Object Declarations
  366.  
  367.  
  368. An object declaration declares an object whose type is given  either  by  a
  369. subtype  indication  or  by  a constrained array definition.  If the object
  370. declaration includes the  assignment  compound  delimiter  followed  by  an
  371. expression,  the  expression  specifies  an  initial value for the declared
  372. object;  the type of the expression must be that of the object.
  373.  
  374. The declared object is a constant if the reserved word constant appears  in
  375. the  object  declaration;   the  declaration  must then include an explicit
  376. initialization.   The  value  of  a  constant  cannot  be  modified   after
  377. initialization.   Formal  parameters of mode in of subprograms and entries,
  378. and generic formal parameters of mode  in,  are  also  constants;   a  loop
  379. parameter  is  a constant within the corresponding loop;  a subcomponent or
  380. slice of a constant is a constant.
  381.  
  382. An object that is not a constant is called a variable (in  particular,  the
  383. object declared by an object declaration that does not include the reserved
  384. word  constant  is  a  variable).   The  only ways to change the value of a
  385. variable are either directly by  an  assignment,  or  indirectly  when  the
  386. variable  is updated (see 6.2) by a procedure or entry call statement (this
  387. action can be performed either on the variable itself, on a subcomponent of
  388. the variable, or on  another  variable  that  has  the  given  variable  as
  389. subcomponent).
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443. The elaboration of an object declaration proceeds as follows:
  444.  
  445. (a)  The subtype indication or the constrained array  definition  is  first
  446.      elaborated.  This establishes the subtype of the object.
  447.  
  448. (b)  If the object declaration includes  an  explicit  initialization,  the
  449.      initial value  is obtained by evaluating the corresponding expression.
  450.      Otherwise  any  implicit  initial  values  for  the  object or for its
  451.      subcomponents are evaluated.
  452.  
  453. (c)  The object is created.
  454.  
  455. (d)  Any initial value (whether explicit or implicit) is  assigned  to  the
  456.      object or to the corresponding subcomponent.
  457.  
  458. Implicit  initial  values  are  defined  for  objects  declared  by  object
  459. declarations, and for components of such objects, in the  following  cases:
  460.  
  461.   -  If the type of an object is an access type, the implicit initial value
  462.      is the null value of the access type.
  463.  
  464.   -  If the type of an object is a task type,  the  implicit  initial  (and
  465.      only) value designates a corresponding task.
  466.  
  467.   -  If the type of an object is a type with discriminants and the  subtype
  468.      of the object is constrained, the implicit initial (and only) value of
  469.      each discriminant is defined by the subtype of the object.
  470.  
  471.   -  If the type of an object is a composite  type,  the  implicit  initial
  472.      value  of  each component that has a default expression is obtained by
  473.      evaluation of this expression, unless the component is a  discriminant
  474.      of a constrained object (the previous case).
  475.  
  476. In  the  case  of  a  component that is itself a composite object and whose
  477. value is defined neither by an explicit initialization  nor  by  a  default
  478. expression,  any  implicit  initial  values for components of the composite
  479. object are defined by the same rules as for a declared object.
  480.  
  481. The steps (a) to (d) are performed in the order indicated.  For  step  (b),
  482. if  the  default  expression  for  a  discriminant  is evaluated, then this
  483. evaluation  is  performed  before   that   of   default   expressions   for
  484. subcomponents that depend on discriminants, and also before that of default
  485. expressions  that  include  the  name  of the discriminant.  Apart from the
  486. previous rule, the evaluation of default expressions is performed  in  some
  487. order that is not defined by the language.
  488.  
  489. The  initialization  of  an  object  (the  declared  object  or  one of its
  490. subcomponents) checks that the initial value belongs to the subtype of  the
  491. object;  for an array object declared by an object declaration, an implicit
  492. subtype  conversion is first applied as for an assignment statement, unless
  493. the object is a constant whose subtype is an unconstrained array type.  The
  494. exception CONSTRAINT_ERROR is raised if this check fails.
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507. The value of a scalar  variable  is  undefined  after  elaboration  of  the
  508. corresponding object declaration unless an initial value is assigned to the
  509. variable by an initialization (explicitly or implicitly).
  510.  
  511. If  the  operand of a type conversion or qualified expression is a variable
  512. that has scalar subcomponents with undefined values, then the values of the
  513. corresponding subcomponents of the result are undefined.  The execution  of
  514. a  program  is erroneous if it attempts to evaluate  a scalar variable with
  515. an undefined value.  Similarly, the execution of a program is erroneous  if
  516. it  attempts to apply a predefined operator to a variable that has a scalar
  517. subcomponent with an undefined value.
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572. Examples of variable declarations:
  573.  
  574.     COUNT, SUM  : INTEGER;
  575.     SIZE        : INTEGER range 0 .. 10_000 := 0;
  576.     SORTED      : BOOLEAN := FALSE;
  577.     COLOR_TABLE : array(1 .. N) of COLOR;
  578.     OPTION      : BIT_VECTOR(1 .. 10) := (others => TRUE);
  579.  
  580. Examples of constant declarations:
  581.  
  582.     LIMIT     : constant INTEGER := 10_000;
  583.     LOW_LIMIT : constant INTEGER := LIMIT/10;
  584.     TOLERANCE : constant REAL := DISPERSION(1.15);
  585.  
  586. Note:
  587.  
  588. The expression  initializing  a  constant  object  need  not  be  a  static
  589. expression  (see  4.9).   In  the  above  examples, LIMIT and LOW_LIMIT are
  590. initialized with static expressions, but TOLERANCE is not if DISPERSION  is
  591. a user-defined function.
  592.  
  593. References:  access type 3.8, assignment 5.2, assignment compound delimiter
  594. 5.2,  component  3.3, composite type 3.3, constrained array definition 3.6,
  595. constrained subtype 3.3, constraint_error exception 11.1,  conversion  4.6,
  596. declaration 3.1, default expression for a discriminant 3.7, default initial
  597. value  for  an  access  type 3.8, depend on a discriminant 3.7.1, designate
  598. 3.8,  discriminant  3.3,  elaboration  3.9,  entry  9.5,  evaluation   4.5,
  599. expression  4.4,  formal parameter 6.1, generic formal parameter 12.1 12.3,
  600. generic unit 12, in some order  1.6,  limited  type  7.4.4,  mode  in  6.1,
  601. package  7,  predefined  operator  4.5,  primary  4.4,  private  type  7.4,
  602. qualified expression 4.7, reserved word 2.9, scalar type 3.5, slice  4.1.2,
  603. subcomponent 3.3, subprogram 6, subtype 3.3, subtype indication 3.3.2, task
  604. 9, task type 9.2, type 3.3, visible part 7.2
  605.  
  606.  
  607.  
  608. > 3.2.2  Number Declarations
  609.  
  610.  
  611. A  number  declaration is a special form of constant declaration.  The type
  612. of  the  static  expression  given  for  the  initialization  of  a  number
  613. declaration   must  be  either  the  type  universal_integer  or  the  type
  614. universal_real.  The constant declared by a number declaration is called  a
  615. named number and has the type of the static expression.
  616.  
  617. Note:
  618.  
  619. The  rules  concerning  expressions  of  a  universal type are explained in
  620. section 4.10.  It is a consequence of these rules  that  if  every  primary
  621. contained  in  the  expression  is  of the type universal_integer, then the
  622. named number is also of this type.  Similarly, if every primary is  of  the
  623. type universal_real, then the named number is also of this type.
  624.  
  625. Examples of number declarations:
  626.  
  627.     PI            : constant := 3.14159_26536; -- a real number
  628.     TWO_PI        : constant := 2.0*PI;        -- a real number
  629.     MAX           : constant := 500;           -- an integer number
  630.     POWER_16      : constant := 2**16;         -- the integer 65_536
  631.     ONE, UN, EINS : constant := 1;             -- three different names for 1
  632.  
  633.  
  634. References:   identifier 2.3, primary 4.4, static expression 4.9, type 3.3,
  635. universal_integer type 3.5.4, universal_real  type  3.5.6,  universal  type
  636. 4.10
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692. > 3.3  Types and Subtypes
  693.  
  694.  
  695. A type is characterized by a set of values and a set of operations.
  696.  
  697. There exist several classes of types.  Scalar types are integer types, real
  698. types,  and  types defined by enumeration of their values;  values of these
  699. types have no components.   Array and record types are composite;  a  value
  700. of a composite type consists of component values.  An access type is a type
  701. whose  values provide access to objects.  Private types are types for which
  702. the set of possible values is well defined, but not directly  available  to
  703. the  users  of  such types.  Finally, there are task types.  (Private types
  704. are described in chapter 7, task types are  described  in  chapter  9,  the
  705. other classes of types are described in this chapter.)
  706.  
  707. Certain   record   and   private   types  have  special  components  called
  708. discriminants whose values distinguish alternative forms of values  of  one
  709. of  these  types.   If  a private type has discriminants, they are known to
  710. users of the type.  Hence a private type is only known  by  its  name,  its
  711. discriminants if any, and by the corresponding set of operations.
  712.  
  713. The  set  of possible values for an object of a given type can be subjected
  714. to a condition that is called a constraint (the case where  the  constraint
  715. imposes  no  restriction  is  also included);  a value is said to satisfy a
  716. constraint if it satisfies the corresponding condition.   A  subtype  is  a
  717. type together with a constraint;  a value is said to belong to a subtype of
  718. a  given  type if it belongs to the type and satisfies the constraint;  the
  719. given type is called the base type of the subtype.  A type is a subtype  of
  720. itself;   such  a subtype is said to be unconstrained:  it corresponds to a
  721. condition that imposes no restriction.  The base type of a type is the type
  722. itself.
  723.  
  724. The set of operations defined for a subtype of a given  type  includes  the
  725. operations that are defined for the type;  however the assignment operation
  726. to a variable having a given subtype only assigns values that belong to the
  727. subtype.   Additional  operations,  such  as  qualification (in a qualified
  728. expression), are implicitly defined by a subtype declaration.
  729.  
  730. Certain types have default initial values defined for objects of the  type;
  731. certain  other  types  have  default expressions defined for some or all of
  732. their components.  Certain operations of  types  and  subtypes  are  called
  733. attributes;   these operations are denoted by the form of name described in
  734. section 4.1.4.
  735.  
  736. The term subcomponent is used in this manual in place of the term component
  737. to indicate either a component, or a  component  of  another  component  or
  738. subcomponent.   Where  other subcomponents are excluded, the term component
  739. is used instead.
  740.  
  741. A given type must not have a subcomponent whose  type  is  the  given  type
  742. itself.
  743.  
  744. The  name  of  a  class  of types is used in this manual as a qualifier for
  745. objects and values that have a type of the class considered.  For  example,
  746. the  term "array object" is used for an object whose type is an array type;
  747. similarly, the term "access value" is used for a value of an  access  type.
  748.  
  749. Note:
  750.  
  751. The  set of values of a subtype is a subset of the values of the base type.
  752. This subset need not be a proper subset;  it can be an empty subset.
  753.  
  754. References:  access type 3.8, array type  3.6,  assignment  5.2,  attribute
  755. 4.1.4,  component  of an array 3.6, component of a record 3.7, discriminant
  756. constraint 3.7.2, enumeration type 3.5.1, integer type 3.5.4, object 3.2.1,
  757. private type 7.4, qualified expression 4.7, real type  3.5.6,  record  type
  758. 3.7, subtype declaration 3.3.2, task type 9.1, type declaration 3.3.1
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812. > 3.3.1  Type Declarations
  813.  
  814.  
  815. A type declaration declares a type.
  816.  
  817.     type_declaration ::=  full_type_declaration
  818.        | incomplete_type_declaration | private_type_declaration
  819.  
  820.     full_type_declaration ::=
  821.          type identifier [discriminant_part] is type_definition;
  822.  
  823.     type_definition ::=
  824.          enumeration_type_definition | integer_type_definition
  825.        | real_type_definition        | array_type_definition
  826.        | record_type_definition      | access_type_definition
  827.        | derived_type_definition
  828.  
  829. The  elaboration  of a full type declaration consists of the elaboration of
  830. the discriminant part, if  any  (except  in  the  case  of  the  full  type
  831. declaration  for  an  incomplete  or  private type declaration), and of the
  832. elaboration of the type definition.
  833.  
  834. The types created by the  elaboration  of  distinct  type  definitions  are
  835. distinct  types.   Moreover,  the  elaboration of the type definition for a
  836. numeric or derived type creates both a base type and a subtype of the  base
  837. type;   the  same  holds for a constrained array definition (one of the two
  838. forms of array type definition).
  839.  
  840. The simple name declared by a full type declaration  denotes  the  declared
  841. type,  unless  the type declaration declares both a base type and a subtype
  842. of the base type, in which case the simple name denotes  the  subtype,  and
  843. the  base  type  is anonymous.  A type is said to be anonymous if it has no
  844. simple name.  For explanatory purposes,  this  reference  manual  sometimes
  845. refers  to an anonymous type by a pseudo-name, written in italics, and uses
  846. such  pseudo-names  at  places  where  the  syntax  normally  requires   an
  847. identifier.
  848.  
  849. Examples of type definitions:
  850.  
  851.     (WHITE, RED, YELLOW, GREEN, BLUE, BROWN, BLACK)
  852.     range1 .. 72
  853.     array(1 .. 10) of INTEGER
  854.  
  855. Examples of type declarations:
  856.  
  857.     type COLOR  is (WHITE, RED, YELLOW, GREEN, BLUE, BROWN, BLACK);
  858.     type COLUMN is range 1 .. 72;
  859.     type TABLE  is array(1 .. 10) of INTEGER;
  860.  
  861. Notes:
  862.  
  863. Two  type  definitions  always  define two distinct types, even if they are
  864. textually identical.   Thus,  the  array  type  definitions  given  in  the
  865. declarations of A and B below define distinct types.
  866.  
  867.     A : array(1 .. 10) of BOOLEAN;
  868.     B : array(1 .. 10) of BOOLEAN;
  869.  
  870. If  A  and  B are declared by a multiple object declaration as below, their
  871. types are nevertheless different, since the multiple object declaration  is
  872. equivalent to the above two single object declarations.
  873.  
  874.     A, B : array(1 .. 10) of BOOLEAN;
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932. Incomplete  type  declarations are used for the definition of recursive and
  933. mutually dependent types (see 3.8.1).  Private type declarations  are  used
  934. in  package  specifications  and in generic parameter declarations (see 7.4
  935. and 12.1).
  936.  
  937. References:  access type definition 3.8, array type  definition  3.6,  base
  938. type  3.3,  constrained  array  definition  3.6,  constrained  subtype 3.3,
  939. declaration  3.1,  derived  type  3.4,   derived   type   definition   3.4,
  940. discriminant  part  3.7.1,  elaboration  3.9,  enumeration  type definition
  941. 3.5.1, identifier 2.3, incomplete  type  declaration  3.8.1,  integer  type
  942. definition  3.5.4,  multiple  object  declaration  3.2,  numeric  type 3.5,
  943. private type declaration 7.4, real type  definition  3.5.6,  reserved  word
  944. 2.9, type 3.3
  945.  
  946.  
  947.  
  948. > 3.3.2  Subtype Declarations
  949.  
  950.  
  951. A subtype declaration declares a subtype.
  952.  
  953.     subtype_declaration ::=
  954.        subtype identifier is subtype_indication;
  955.  
  956.     subtype_indication ::=  type_mark [constraint]
  957.  
  958.     type_mark ::= type_name | subtype_name
  959.  
  960.     constraint ::=
  961.          range_constraint | floating_point_constraint | fixed_point_constraint
  962.        | index_constraint | discriminant_constraint
  963.  
  964. A  type  mark denotes a type or a subtype.  If a type mark is the name of a
  965. type,  the  type  mark  denotes  this  type  and  also  the   corresponding
  966. unconstrained subtype.  The base type of a type mark is, by definition, the
  967. base type of the type or subtype denoted by the type mark.
  968.  
  969. A  subtype  indication defines a subtype of the base type of the type mark.
  970.  
  971. If an index constraint appears after a type mark in a  subtype  indication,
  972. the  type mark must not already impose an index constraint.  Likewise for a
  973. discriminant  constraint,  the  type  mark  must  not  already   impose   a
  974. discriminant constraint.
  975.  
  976. The elaboration of a subtype declaration consists of the elaboration of the
  977. subtype  indication.   The  elaboration  of  a subtype indication creates a
  978. subtype.  If the subtype indication does  not  include  a  constraint,  the
  979. subtype is the same as that denoted by the type mark.  The elaboration of a
  980. subtype indication that includes a constraint proceeds as follows:
  981.  
  982. (a)  The constraint is first elaborated.
  983.  
  984. (b)  A check is then made that the constraint is compatible with  the  type
  985.      or subtype denoted by the type mark.
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997. The  condition  imposed  by  a  constraint  is the condition obtained after
  998. elaboration of the constraint.  (The rules of  constraint  elaboration  are
  999. such  that  the expressions and  ranges of constraints are evaluated by the
  1000. elaboration of these constraints.)  The rules  defining  compatibility  are
  1001. given  for each form of constraint in the appropriate section.  These rules
  1002. are such that if a constraint  is  compatible  with  a  subtype,  then  the
  1003. condition imposed by the constraint cannot contradict any condition already
  1004. imposed  by  the  subtype on its values.  The exception CONSTRAINT_ERROR is
  1005. raised if any check of compatibility fails.
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062. Examples of subtype declarations:
  1063.  
  1064.  
  1065.     subtype RAINBOW   is COLOR range RED .. BLUE;        --  see 3.3.1
  1066.     subtype RED_BLUE  is RAINBOW;
  1067.     subtype INT       is INTEGER;
  1068.     subtype SMALL_INT is INTEGER range -10 .. 10;
  1069.     subtype UP_TO_K   is COLUMN range 1 .. K;            --  see 3.3.1
  1070.     subtype SQUARE    is MATRIX(1 .. 10, 1 .. 10);       --  see 3.6
  1071.     subtype MALE      is PERSON(SEX => M);               --  see 3.8
  1072.  
  1073. Note:
  1074.  
  1075. A subtype declaration does not define a new type.
  1076.  
  1077. References:  base  type  3.3,  compatibility  of  discriminant  constraints
  1078. 3.7.2,  compatibility  of  fixed  point constraints 3.5.9, compatibility of
  1079. floating point constraints 3.5.7, compatibility of index constraints 3.6.1,
  1080. compatibility of range constraints 3.5,  constraint_error  exception  11.1,
  1081. declaration   3.1,   discriminant   3.3,   discriminant  constraint  3.7.2,
  1082. elaboration 3.9, evaluation 4.5, expression 4.4, floating point  constraint
  1083. 3.5.7,   fixed  point  constraint  3.5.9,  index  constraint  3.6.1,  range
  1084. constraint 3.5, reserved word 2.9, subtype 3.3, type 3.3, type name  3.3.1,
  1085. unconstrained subtype 3.3
  1086.  
  1087.  
  1088.  
  1089. > 3.3.3  Classification of Operations
  1090.  
  1091.  
  1092. The   set  of  operations  of  a  type  includes  the  explicitly  declared
  1093. subprograms that have a parameter or result of the type;  such  subprograms
  1094. are necessarily declared after the type declaration.
  1095.  
  1096. The  remaining  operations  are  each  implicitly declared for a given type
  1097. declaration, immediately  after  the  type  definition.   These  implicitly
  1098. declared operations comprise the basic operations, the predefined operators
  1099. (see  4.5),  and  enumeration  literals.   In  the  case  of a derived type
  1100. declaration,  the  implicitly  declared  operations  include  any   derived
  1101. subprograms.    The   operations  implicitly  declared  for  a  given  type
  1102. declaration occur after the type declaration and before the  next  explicit
  1103. declaration,  if  any.   The  implicit  declarations of derived subprograms
  1104. occur last.
  1105.  
  1106. A basic operation is an operation that is inherent in one of the following:
  1107.  
  1108.   -  An assignment  (in  assignment  statements  and  initializations),  an
  1109.      allocator, a membership test, or a short-circuit control form.
  1110.  
  1111.   -  A selected component, an indexed component, or a slice.
  1112.  
  1113.   -  A  qualification  (in  qualified  expressions),   an   explicit   type
  1114.      conversion,  or  an  implicit  type  conversion  of  a  value  of type
  1115.      universal_integer or universal_real  to  the  corresponding  value  of
  1116.      another numeric type.
  1117.  
  1118.   -  A numeric literal (for a universal type), the  literal  null  (for  an
  1119.      access type), a string literal, an aggregate, or an attribute.
  1120.  
  1121. For every type or subtype T, the following attribute is defined:
  1122.  
  1123. T'BASE     The base type of T.  This  attribute  is  allowed  only  as  the
  1124.            prefix   of   the  name  of  another  attribute:   for  example,
  1125.            T'BASE'FIRST.
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183. Note:
  1184.  
  1185. Each literal is an operation  whose  evaluation  yields  the  corresponding
  1186. value  (see  4.2).  Likewise, an aggregate is an operation whose evaluation
  1187. yields a value of a composite type (see 4.3).  Some operations  of  a  type
  1188. operate  on  values  of  the  type,  for  example, predefined operators and
  1189. certain subprograms and attributes.  The evaluation of some operations of a
  1190. type returns a value  of  the  type,  for  example,  literals  and  certain
  1191. functions,   attributes,   and  predefined  operators.   Assignment  is  an
  1192. operation that operates on an object and a value.  The  evaluation  of  the
  1193. operation corresponding to a selected component, an indexed component, or a
  1194. slice, yields the object or value denoted by this form of name.
  1195.  
  1196.  
  1197. References:  aggregate 4.3, allocator 4.8, assignment 5.2, attribute 4.1.4,
  1198. character   literal  2.5,  composite  type  3.3,  conversion  4.6,  derived
  1199. subprogram 3.4, enumeration literal 3.5.1, formal parameter  6.1,  function
  1200. 6.5,  indexed component 4.1.1, initial value 3.2.1, literal 4.2, membership
  1201. test 4.5 4.5.2, null literal 3.8, numeric literal 2.4,  numeric  type  3.5,
  1202. object  3.2.1,  6.1,  predefined  operator  4.5,  qualified expression 4.7,
  1203. selected component 4.1.3,  short-circuit  control  form  4.5  4.5.1,  slice
  1204. 4.1.2,  string  literal  2.6,  subprogram  6,  subtype  3.3, type 3.3, type
  1205. declaration 3.3.1, universal_integer type 3.5.4, universal_real type 3.5.6,
  1206. universal type 4.10
  1207.  
  1208.  
  1209.  
  1210. > 3.4  Derived Types
  1211.  
  1212.  
  1213. A derived type definition defines a new (base) type  whose  characteristics
  1214. are  derived from those of a parent type;  the new type is called a derived
  1215. type.  A derived type definition further defines a derived  subtype,  which
  1216. is a subtype of the derived type.
  1217.  
  1218.     derived_type_definition ::= new subtype_indication
  1219.  
  1220. The  subtype indication that occurs after the reserved word new defines the
  1221. parent subtype.  The parent type is the base type of  the  parent  subtype.
  1222. If  a constraint exists for the parent subtype, a similar constraint exists
  1223. for the  derived  subtype;   the  only  difference  is  that  for  a  range
  1224. constraint,  and  likewise  for  a  floating or fixed point constraint that
  1225. includes a range constraint, the value of each bound  is  replaced  by  the
  1226. corresponding  value  of  the  derived  type.   The  characteristics of the
  1227. derived type are defined as follows:
  1228.  
  1229.   -  The derived type belongs to the same class  of  types  as  the  parent
  1230.      type.   The  set  of possible values for the derived type is a copy of
  1231.      the set of possible values for the parent type.  If the parent type is
  1232.      composite, then the same components exist for the  derived  type,  and
  1233.      the subtype of corresponding components is the same.
  1234.  
  1235.   -  For each basic operation of the parent type, there is a  corresponding
  1236.      basic  operation  of  the derived type.  Explicit type conversion of a
  1237.      value of the parent type into the corresponding value of  the  derived
  1238.      type is allowed and vice versa as explained in section 4.6.
  1239.  
  1240.   -  For each enumeration literal or predefined operator of the parent type
  1241.      there is a corresponding operation for the derived type.
  1242.  
  1243.   -  If the parent type is a task type, then for each entry of  the  parent
  1244.      type there is a corresponding entry for the derived type.
  1245.  
  1246.   -  If a default expression exists for a component of an object having the
  1247.      parent  type,  then  the  same  default  expression  is  used  for the
  1248.      corresponding component of an object having the derived type.
  1249.  
  1250.   -  If the parent type is an access type, then the parent and the  derived
  1251.      type  share the same collection;  there is a null access value for the
  1252.      derived type and it is the default initial value of that type.
  1253.  
  1254.   -  If an explicit representation clause exists for the parent type and if
  1255.      this clause appears before the derived type definition, then there  is
  1256.      a  corresponding  representation  clause  (an  implicit  one)  for the
  1257.      derived type.
  1258.  
  1259.   -  Certain subprograms that are operations of the parent type are said to
  1260.      be derivable.  For each derivable subprogram of the parent type, there
  1261.      is a corresponding derived subprogram for the derived type.  Two kinds
  1262.      of derivable subprograms exist.  First, if the parent type is declared
  1263.      immediately within the visible part of a package,  then  a  subprogram
  1264.      that is itself explicitly declared immediately within the visible part
  1265.      becomes  derivable  after  the  end  of  the visible part, if it is an
  1266.      operation of the parent type.   (The  explicit  declaration  is  by  a
  1267.      subprogram   declaration,   a   renaming  declaration,  or  a  generic
  1268.      instantiation.)  Second, if the parent type is itself a derived  type,
  1269.      then  any  subprogram  that  has  been  derived by this parent type is
  1270.      further derivable, unless the parent type is declared in  the  visible
  1271.      part  of a package and the derived subprogram is hidden by a derivable
  1272.      subprogram of the first kind.
  1273.  
  1274. Each operation of the derived type is implicitly declared at the  place  of
  1275. the  derived  type  declaration.   The implicit declarations of any derived
  1276. subprograms occur last.
  1277.  
  1278. The specification  of  a  derived  subprogram  is  obtained  implicitly  by
  1279. systematic  replacement  of  the  parent  type  by  the derived type in the
  1280. specification of the derivable subprogram.  Any subtype of the parent  type
  1281. is  likewise  replaced  by  a  subtype  of  the derived type with a similar
  1282. constraint (as for the transformation of a constraint of the parent subtype
  1283. into the corresponding constraint of the derived  subtype).   Finally,  any
  1284. expression  of  the  parent  type  is  made  to  be  the  operand of a type
  1285. conversion that yields a result of the derived type.
  1286.  
  1287. Calling a derived subprogram is equivalent  to  calling  the  corresponding
  1288. subprogram  of  the  parent type, in which each actual parameter that is of
  1289. the derived type is replaced by a type conversion of this actual  parameter
  1290. to the parent type (this means that a conversion to the parent type happens
  1291. before  the  call for the modes in and in out;  a reverse conversion to the
  1292. derived type happens after the call for the  modes  in  out  and  out,  see
  1293. 6.4.1).   In  addition, if the result of a called function is of the parent
  1294. type, this result is converted to the derived type.
  1295.  
  1296. If a derived or private type is declared  immediately  within  the  visible
  1297. part  of  a  package, then, within this visible part, this type must not be
  1298. used as the parent type of a derived type definition.  (For private  types,
  1299. see also section 7.4.1.)
  1300.  
  1301. For the elaboration of a derived type definition, the subtype indication is
  1302. first  elaborated,  the  derived  type  is  then  created, and finally, the
  1303. derived subtype is created.
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315. Examples:
  1316.  
  1317.     type LOCAL_COORDINATE is new COORDINATE;   --  two different types
  1318.     type MIDWEEK is new DAY range TUE .. THU;  --  see 3.5.1
  1319.     type COUNTER is new POSITIVE;              --  same range as POSITIVE
  1320.  
  1321.     type SPECIAL_KEY is new KEY_MANAGER.KEY;   --  see 7.4.2
  1322.     -- the derived subprograms have the following specifications:
  1323.  
  1324.     -- procedure GET_KEY(K : out SPECIAL_KEY);
  1325.     -- function "<"(X,Y : SPECIAL_KEY) return BOOLEAN;
  1326.  
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380. Notes:
  1381.  
  1382. The rules of derivation of basic operations and enumeration literals  imply
  1383. that  the  notation for any literal or aggregate of the derived type is the
  1384. same as for the parent type;  such literals and aggregates are said  to  be
  1385. overloaded.   Similarly,  it  follows  that  the  notation  for  denoting a
  1386. component, a discriminant, an entry, a slice, or an attribute is  the  same
  1387. for the derived type as for the parent type.
  1388.  
  1389. Hiding  of a derived subprogram is allowed even within the same declarative
  1390. region (see 8.3).  A derived subprogram hides a  predefined  operator  that
  1391. has the same parameter and result type profile (see 6.6).
  1392.  
  1393. A  generic  subprogram  declaration  is  not  derivable since it declares a
  1394. generic unit rather than a subprogram.  On the other hand, an instantiation
  1395. of a generic subprogram is a (nongeneric) subprogram, which is derivable if
  1396. it satisfies the requirements for derivability of subprograms.
  1397.  
  1398. If the parent type is a boolean type, the predefined  relational  operators
  1399. of  the  derived  type deliver a result of the predefined type BOOLEAN (see
  1400. 4.5.2).
  1401.  
  1402. If a representation clause is given for the parent type but  appears  after
  1403. the  derived  type declaration, then no corresponding representation clause
  1404. applies to the derived type;  hence an explicit representation  clause  for
  1405. such a derived type is allowed.
  1406.  
  1407. For  a  derived subprogram, if a parameter belongs to the derived type, the
  1408. subtype of this parameter need not  have  any  value  in  common  with  the
  1409. derived subtype.
  1410.  
  1411. References:   access  value  3.8,  actual  parameter  6.4.1, aggregate 4.3,
  1412. attribute 4.1.4, base type 3.3, basic operation 3.3.3, boolean type  3.5.3,
  1413. bound  of  a  range  3.5, class of type 3.3, collection 3.8, component 3.3,
  1414. composite type  3.3,  constraint  3.3,  conversion  4.6,  declaration  3.1,
  1415. declarative region 8.1, default expression 3.2.1, default initial value for
  1416. an   access  type  3.8,  discriminant  3.3,  elaboration  3.9,  entry  9.5,
  1417. enumeration literal 3.5.1, floating point  constraint  3.5.7,  fixed  point
  1418. constraint   3.5.9,  formal  parameter  6.1,  function  call  6.4,  generic
  1419. declaration 12.1, immediately within 8.1, implicit declaration 3.1, literal
  1420. 4.2, mode 6.1, overloading 6.6 8.7, package 7, package  specification  7.1,
  1421. parameter  association  6.4,  predefined  operator  4.5,  private type 7.4,
  1422. procedure  6,  procedure  call  statement  6.4,   range   constraint   3.5,
  1423. representation  clause  13.1, reserved word 2.9, slice 4.1.2, subprogram 6,
  1424. subprogram specification 6.1, subtype indication 3.3.2, subtype  3.3,  type
  1425. 3.3, type definition 3.3.1, visible part 7.2
  1426.  
  1427.  
  1428.  
  1429. > 3.5  Scalar Types
  1430.  
  1431.  
  1432. Scalar  types  comprise  enumeration  types, integer types, and real types.
  1433. Enumeration types and integer types are called discrete types;  each  value
  1434. of  a  discrete  type  has  a  position  number  which is an integer value.
  1435. Integer types and real types are called numeric types.   All  scalar  types
  1436. are  ordered,  that  is,  all relational operators are predefined for their
  1437. values.
  1438.  
  1439.     range_constraint ::=  range range
  1440.  
  1441.     range ::=  range_attribute
  1442.        | simple_expression .. simple_expression
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461.  
  1462.  
  1463.  
  1464.  
  1465.  
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500. A range specifies a subset of values of a scalar type.  The range  L  ..  R
  1501. specifies  the values from L to R inclusive if the relation L <= R is true.
  1502. The values L and R are called the lower bound and upper bound of the range,
  1503. respectively.  A value V is said  to  satisfy  a  range  constraint  if  it
  1504. belongs  to  the  range;  the value V is said to belong to the range if the
  1505. relations L <= V and V <= R are both TRUE.  A null range  is  a  range  for
  1506. which  the  relation R < L is TRUE;  no value belongs to a null range.  The
  1507. operators <= and < in the above definitions are the predefined operators of
  1508. the scalar type.
  1509.  
  1510. If a range constraint is used in a subtype indication, either  directly  or
  1511. as  part  of  a  floating or fixed point constraint, the type of the simple
  1512. expressions (likewise,  of the bounds of a range  attribute)  must  be  the
  1513. same  as the base type of the type mark of the subtype indication.  A range
  1514. constraint is compatible with a subtype if each bound of the range  belongs
  1515. to the subtype, or if the range constraint defines a null range;  otherwise
  1516. the range constraint is not compatible with the subtype.
  1517.  
  1518. The  elaboration  of  a  range constraint consists of the evaluation of the
  1519. range.  The evaluation of a range defines its lower  bound  and  its  upper
  1520. bound.   If  simple  expressions  are  given  to  specify  the  bounds, the
  1521. evaluation of the range evaluates these simple expressions  in  some  order
  1522. that is not defined by the language.
  1523.  
  1524. Attributes
  1525.  
  1526. For  any scalar type T or for any subtype T of a scalar type, the following
  1527. attributes are defined:
  1528.  
  1529. T'FIRST     Yields the lower bound of T.  The value of this  attribute  has
  1530.             the same type as T.
  1531.  
  1532. T'LAST      Yields the upper bound of T.  The value of this  attribute  has
  1533.             the same type as T.
  1534.  
  1535. Note:
  1536.  
  1537. Indexing and iteration rules use values of discrete types.
  1538.  
  1539. References:   attribute  4.1.4,  constraint  3.3,  enumeration  type 3.5.1,
  1540. erroneous 1.6, evaluation 4.5, fixed point constraint 3.5.9, floating point
  1541. constraint 3.5.7, index 3.6, integer type 3.5.4, loop statement 5.5,  range
  1542. attribute  3.6.2, real type 3.5.6, relational operator 4.5 4.5.2, satisfy a
  1543. constraint 3.3, simple expression 4.4, subtype indication 3.3.2, type  mark
  1544. 3.3.2
  1545.  
  1546.  
  1547.  
  1548. > 3.5.1  Enumeration Types
  1549.  
  1550.  
  1551. An enumeration type definition defines an enumeration type.
  1552.  
  1553.     enumeration_type_definition ::=
  1554.        (enumeration_literal_specification {, enumeration_literal_specification})
  1555.  
  1556.     enumeration_literal_specification ::=  enumeration_literal
  1557.  
  1558.     enumeration_literal ::=  identifier | character_literal
  1559.  
  1560. The  identifiers  and  character  literals  listed  by  an enumeration type
  1561. definition must be distinct.  Each enumeration literal specification is the
  1562. declaration of the corresponding enumeration literal:  this declaration  is
  1563. equivalent  to  the declaration of a parameterless function, the designator
  1564. being the enumeration literal, and the result type  being  the  enumeration
  1565. type.   The  elaboration  of  an  enumeration  type  definition  creates an
  1566. enumeration type;  this elaboration  includes  that  of  every  enumeration
  1567. literal specification.
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621. Each  enumeration  literal  yields  a  different  enumeration  value.   The
  1622. predefined order relations between enumeration values follow the  order  of
  1623. corresponding  position  numbers.   The position number of the value of the
  1624. first listed enumeration literal is zero;  the  position  number  for  each
  1625. other enumeration literal is one more than for its predecessor in the list.
  1626.  
  1627. If  the  same identifier or character literal is specified in more than one
  1628. enumeration type definition, the corresponding  literals  are  said  to  be
  1629. overloaded.  At any place where an overloaded enumeration literal occurs in
  1630. the  text  of  a  program,  the  type  of  the  enumeration literal must be
  1631. determinable from the context (see 8.7).
  1632.  
  1633. Examples:
  1634.  
  1635.     type DAY    is (MON, TUE, WED, THU, FRI, SAT, SUN);
  1636.     type SUIT   is (CLUBS, DIAMONDS, HEARTS, SPADES);
  1637.     type GENDER is (M, F);
  1638.     type LEVEL  is (LOW, MEDIUM, URGENT);
  1639.     type COLOR  is (WHITE, RED, YELLOW, GREEN, BLUE, BROWN, BLACK);
  1640.     type LIGHT  is (RED, AMBER, GREEN); -- RED and GREEN are overloaded
  1641.  
  1642.     type HEXA   is ('A', 'B', 'C', 'D', 'E', 'F');
  1643.     type MIXED  is ('A', 'B', '*', B, NONE, '?', '%');
  1644.  
  1645.     subtype WEEKDAY is DAY   range MON .. FRI;
  1646.     subtype MAJOR   is SUIT  range HEARTS .. SPADES;
  1647.     subtype RAINBOW is COLOR range RED .. BLUE;  --  the color RED, not the light
  1648.  
  1649. Note:
  1650.  
  1651. If an enumeration literal occurs in  a  context  that  does  not  otherwise
  1652. suffice  to  determine  the  type of the literal, then qualification by the
  1653. name of the enumeration type is one way to resolve the ambiguity (see 8.7).
  1654.  
  1655.  
  1656. References:   character  literal  2.5,  declaration  3.1,  designator  6.1,
  1657. elaboration  3.9,  6.1, function 6.5, identifier 2.3, name 4.1, overloading
  1658. 6.6 8.7, position number 3.5, qualified expression 4.7, relational operator
  1659. 4.5 4.5.2, type 3.3, type definition 3.3.1
  1660.  
  1661.  
  1662.  
  1663. > 3.5.2  Character Types
  1664.  
  1665.  
  1666. An enumeration type is said to be a character type if at least one  of  its
  1667. enumeration literals is a character literal.  The predefined type CHARACTER
  1668. is  a  character  type  whose  values  are  the 128 characters of the ASCII
  1669. character set.  Each of the 95 graphic characters of this character set  is
  1670. denoted by the corresponding character literal.
  1671.  
  1672. Example:
  1673.  
  1674.     type ROMAN_DIGIT is ('I', 'V', 'X', 'L', 'C', 'D', 'M');
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686. Notes:
  1687.  
  1688. The predefined package ASCII includes the declaration of constants denoting
  1689. control  characters  and  of constants denoting graphic characters that are
  1690. not in the basic character set.
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751. A conventional character set such as EBCDIC can be declared as a  character
  1752. type;   the  internal  codes  of  the  characters  can  be  specified by an
  1753. enumeration representation clause as explained in section 13.3.
  1754.  
  1755. References:  ascii predefined package C,  basic  character  2.1,  character
  1756. literal  2.5,  constant  3.2.1,  declaration  3.1,  enumeration type 3.5.1,
  1757. graphic character 2.1, identifier 2.3, literal 4.2, predefined type C, type
  1758. 3.3
  1759.  
  1760.  
  1761.  
  1762. > 3.5.3  Boolean Types
  1763.  
  1764.  
  1765. There is a predefined enumeration type named BOOLEAN.  It contains the  two
  1766. literals  FALSE and TRUE ordered with the relation FALSE < TRUE.  A boolean
  1767. type is either the type BOOLEAN or a type  that  is  derived,  directly  or
  1768. indirectly, from a boolean type.
  1769.  
  1770. References:   derived type 3.4, enumeration literal 3.5.1, enumeration type
  1771. 3.5.1, relational operator 4.5 4.5.2, type 3.3
  1772.  
  1773.  
  1774.  
  1775. > 3.5.4  Integer Types
  1776.  
  1777.  
  1778. An integer type definition defines an integer  type  whose  set  of  values
  1779. includes at least those of the specified range.
  1780.  
  1781.     integer_type_definition ::=  range_constraint
  1782.  
  1783. If  a range constraint is used as an integer type definition, each bound of
  1784. the range must be defined by a static expression of some integer type,  but
  1785. the  two  bounds need not have the same integer type.  (Negative bounds are
  1786. allowed.)
  1787.  
  1788. A type declaration of the form:
  1789.  
  1790.     type T is range L .. R;
  1791.  
  1792. is, by definition, equivalent to the following declarations:
  1793.  
  1794.     type integer_type is new predefined_integer_type;
  1795.     subtype T is integer_type range integer_type(L) .. integer_type(R);
  1796.  
  1797. where integer_type is an anonymous type, and where the  predefined  integer
  1798. type  is  implicitly  selected  by the implementation, so as to contain the
  1799. values L to R inclusive.  The integer type declaration is illegal  if  none
  1800. of  the  predefined  integer  types  satisfies  this requirement, excepting
  1801. universal_integer.  The elaboration of the declaration of an  integer  type
  1802. consists   of   the   elaboration   of  the  equivalent  type  and  subtype
  1803. declarations.
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816. The predefined integer types include the type INTEGER.   An  implementation
  1817. may  also  have  predefined  types  such as SHORT_INTEGER and LONG_INTEGER,
  1818. which have (substantially) shorter and longer  ranges,  respectively,  than
  1819. INTEGER.   The  range  of each of these types must be symmetric about zero,
  1820. excepting an extra negative value which may exist in some  implementations.
  1821. The base type of each of these types is the type itself.
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881. Integer  literals  are the literals of an anonymous predefined integer type
  1882. that is called universal_integer in this reference manual.   Other  integer
  1883. types  have  no  literals.   However, for each integer type there exists an
  1884. implicit conversion  that  converts  a  universal_integer  value  into  the
  1885. corresponding  value (if any) of the integer type.  The circumstances under
  1886. which these implicit conversions are invoked are described in section  4.6.
  1887.  
  1888. The  position  number of an integer value is the corresponding value of the
  1889. type universal_integer.
  1890.  
  1891. The same arithmetic operators are predefined for  all  integer  types  (see
  1892. 4.5).   The  exception  NUMERIC_ERROR  is  raised  by  the  execution of an
  1893. operation (in particular an implicit conversion) that  cannot  deliver  the
  1894. correct  result  (that  is,  if the value corresponding to the mathematical
  1895. result is not a  value of the integer type).  However, an implementation is
  1896. not required to raise the exception NUMERIC_ERROR if the operation is  part
  1897. of a larger expression whose result can be computed correctly, as described
  1898. in section 11.6.
  1899.  
  1900. Examples:
  1901.  
  1902.     type PAGE_NUM  is range 1 .. 2_000;
  1903.     type LINE_SIZE is range 1 .. MAX_LINE_SIZE;
  1904.  
  1905.     subtype SMALL_INT   is INTEGER   range -10 .. 10;
  1906.     subtype COLUMN_PTR  is LINE_SIZE range 1 .. 10;
  1907.     subtype BUFFER_SIZE is INTEGER   range 0 .. MAX;
  1908.  
  1909. Notes:
  1910.  
  1911. The name declared by an integer type declaration is a subtype name.  On the
  1912. other  hand,  the  predefined  operators of an integer type deliver results
  1913. whose range is defined by the parent predefined type;  such a  result  need
  1914. not  belong to the declared subtype, in which case an attempt to assign the
  1915. result  to  a  variable  of  the  integer  subtype  raises  the   exception
  1916. CONSTRAINT_ERROR.
  1917.  
  1918. The  smallest  (most  negative)  value  supported by the predefined integer
  1919. types of an implementation is  the  named  number  SYSTEM.MIN_INT  and  the
  1920. largest (most positive) value is SYSTEM.MAX_INT (see 13.7).
  1921.  
  1922. References:   anonymous  type  3.3.1,  belong  to a subtype 3.3, bound of a
  1923. range 3.5, constraint_error exception 11.1, conversion 4.6, identifier 2.3,
  1924. integer literal 2.4, literal 4.2, numeric_error exception 11.1, parent type
  1925. 3.4, predefined operator 4.5, range constraint 3.5, static expression  4.9,
  1926. subtype  declaration  3.3.2, system predefined package 13.7, type 3.3, type
  1927. declaration 3.3.1, type definition 3.3.1, universal type 4.10
  1928.  
  1929.  
  1930.  
  1931. > 3.5.5  Operations of Discrete Types
  1932.  
  1933.  
  1934. The basic operations of a discrete type include the operations involved  in
  1935. assignment,  the  membership  tests, and qualification;  for a boolean type
  1936. they include the short-circuit control forms;  for  an  integer  type  they
  1937. include  the  explicit  conversion  of values of other numeric types to the
  1938. integer  type,  and  the  implicit  conversion  of  values  of   the   type
  1939. universal_integer to the type.
  1940.  
  1941. Finally, for every discrete type or subtype T, the basic operations include
  1942. the  attributes  listed  below.   In this presentation, T is referred to as
  1943. being  a  subtype  (the  subtype  T)  for  any  property  that  depends  on
  1944. constraints imposed by T;  other properties are stated in terms of the base
  1945. type of T.
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991.  
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001. The first group of attributes yield characteristics of the subtype T.  This
  2002. group  includes  the  attribute  BASE (see 3.3.2), the attributes FIRST and
  2003. LAST (see 3.5), the representation attribute SIZE (see  13.7.2),  and   the
  2004. attribute WIDTH defined as follows:
  2005.  
  2006. T'WIDTH     Yields the maximum image length over all values of the  subtype
  2007.             T  (the  image  is  the  sequence of characters returned by the
  2008.             attribute IMAGE, see below).  Yields zero  for  a  null  range.
  2009.             The  value  of this attribute is of the type universal_integer.
  2010.  
  2011. All attributes of the second group are functions with a  single  parameter.
  2012. The corresponding actual parameter is indicated below by X.
  2013.  
  2014. T'POS       This attribute is a function.  The parameter X must be a  value
  2015.             of   the  base  type  of  T.   The  result  type  is  the  type
  2016.             universal_integer.  The result is the position  number  of  the
  2017.             value of the parameter.
  2018.  
  2019. T'VAL       This attribute is a special function with  a  single  parameter
  2020.             which  can be of any integer type.  The result type is the base
  2021.             type of T.  The result is the value whose  position  number  is
  2022.             the  universal_integer value corresponding to X.  The exception
  2023.             CONSTRAINT_ERROR  is  raised  if  the  universal_integer  value
  2024.             corresponding  to  X is not in the range T'POS(T'BASE'FIRST) ..
  2025.             T'POS(T'BASE'LAST).
  2026.  
  2027. T'SUCC      This attribute is a function.  The parameter X must be a  value
  2028.             of  the base type of T.  The result type is the base type of T.
  2029.             The result is the value whose position number  is  one  greater
  2030.             than  that of X.  The exception CONSTRAINT_ERROR is raised if X
  2031.             equals T'BASE'LAST.
  2032.  
  2033. T'PRED      This attribute is a function.  The parameter X must be a  value
  2034.             of  the base type of T.  The result type is the base type of T.
  2035.             The result is the value whose position number is one less  than
  2036.             that  of  X.   The  exception  CONSTRAINT_ERROR  is raised if X
  2037.             equals T'BASE'FIRST.
  2038.  
  2039. T'IMAGE     This attribute is a function.  The parameter X must be a  value
  2040.             of  the base type of T.  The result type is the predefined type
  2041.             STRING.  The result is the image of the value of X, that is,  a
  2042.             sequence  of characters representing the value in display form.
  2043.             The image of an integer  value  is  the  corresponding  decimal
  2044.             literal;   without  underlines,  leading  zeros,  exponent,  or
  2045.             trailing spaces;  but with a single leading character  that  is
  2046.             either  a  minus sign or a space.  The lower bound of the image
  2047.             is one.
  2048.  
  2049.             The image of an enumeration value is either  the  corresponding
  2050.             identifier in upper case or the corresponding character literal
  2051.             (including  the two apostrophes);  neither leading nor trailing
  2052.             spaces are included.  The image of a character C, other than  a
  2053.             graphic   character,   is   implementation-defined;   the  only
  2054.             requirement is that the  image  must  be  such  that  C  equals
  2055.             CHARACTER'VALUE(CHARACTER'IMAGE(C)).
  2056.  
  2057. T'VALUE     This attribute is a function.  The parameter X must be a  value
  2058.             of  the  predefined  type  STRING.  The result type is the base
  2059.             type of T.  Any leading and any trailing spaces of the sequence
  2060.             of characters that corresponds to the parameter are ignored.
  2061.  
  2062.             For an enumeration type, if the sequence of characters has  the
  2063.             syntax of an enumeration literal and if this literal exists for
  2064.             the base type of T, the result is the corresponding enumeration
  2065.             value.   For an integer type, if the sequence of characters has
  2066.             the syntax of an  integer  literal,  with  an  optional  single
  2067.             leading character that is a plus or minus sign, and if there is
  2068.             a corresponding value in the base type of T, the result is this
  2069.             value.   In  any  other case, the exception CONSTRAINT_ERROR is
  2070.             raised.
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122. In addition, the attributes A'SIZE and A'ADDRESS are defined for an  object
  2123. A of a discrete type (see 13.7.2).
  2124.  
  2125. Besides the basic operations, the operations of a discrete type include the
  2126. predefined relational operators.  For enumeration types, operations include
  2127. enumeration literals.  For boolean types, operations include the predefined
  2128. unary  logical negation operator not, and the predefined logical operators.
  2129. For integer types, operations include the predefined arithmetic  operators:
  2130. these  are  the  binary and unary adding operators - and +, all multiplying
  2131. operators, the unary operator abs, and the exponentiating operator.
  2132.  
  2133. The operations of a subtype are the corresponding operations  of  its  base
  2134. type   except   for   the   following:    assignment,   membership   tests,
  2135. qualification, explicit type conversions, and the attributes of  the  first
  2136. group;   the  effect  of  each  of  these operations depends on the subtype
  2137. (assignments, membership tests, qualifications, and conversions  involve  a
  2138. subtype check;  attributes of the first group yield a characteristic of the
  2139. subtype).
  2140.  
  2141. Notes:
  2142.  
  2143. For  a  subtype of a discrete type, the results delivered by the attributes
  2144. SUCC, PRED, VAL, and VALUE need not belong to the subtype;  similarly,  the
  2145. actual  parameters  of  the  attributes POS, SUCC, PRED, and IMAGE need not
  2146. belong to the subtype.  The  following  relations  are  satisfied  (in  the
  2147. absence of an exception) by these attributes:
  2148.  
  2149.     T'POS(T'SUCC(X)) = T'POS(X) + 1
  2150.     T'POS(T'PRED(X)) = T'POS(X) - 1
  2151.  
  2152.     T'VAL(T'POS(X))  = X
  2153.     T'POS(T'VAL(N))  = N
  2154.  
  2155. Examples:
  2156.  
  2157.     --  For the types and subtypes declared in section 3.5.1 we have:
  2158.  
  2159.     --  COLOR'FIRST   = WHITE,   COLOR'LAST   = BLACK
  2160.     --  RAINBOW'FIRST = RED,     RAINBOW'LAST = BLUE
  2161.  
  2162.     --  COLOR'SUCC(BLUE) = RAINBOW'SUCC(BLUE) = BROWN
  2163.     --  COLOR'POS(BLUE)  = RAINBOW'POS(BLUE)  = 4
  2164.     --  COLOR'VAL(0)     = RAINBOW'VAL(0)     = WHITE
  2165.  
  2166.  
  2167. References:   abs operator 4.5 4.5.6, assignment 5.2, attribute 4.1.4, base
  2168. type 3.3, basic operation 3.3.3, binary adding operator 4.5 4.5.3,  boolean
  2169. type  3.5.3,  bound  of a range 3.5, character literal 2.5, constraint 3.3,
  2170. constraint_error  exception  11.1,  conversion  4.6,  discrete  type   3.5,
  2171. enumeration literal 3.5.1, exponentiating operator 4.5 4.5.6, function 6.5,
  2172. graphic character 2.1, identifier 2.3, integer type 3.5.4, logical operator
  2173. 4.5  4.5.1,  membership test 4.5 4.5.2, multiplying operator 4.5 4.5.5, not
  2174. operator 4.5 4.5.6, numeric literal 2.4,  numeric  type  3.5,  object  3.2,
  2175. operation  3.3,  position  number  3.5, predefined operator 4.5, predefined
  2176. type  C,  qualified  expression  4.7,  relational   operator   4.5   4.5.2,
  2177. short-circuit  control form 4.5 4.5.1, string type 3.6.3, subtype 3.3, type
  2178. 3.3,  unary  adding  operator  4.5  4.5.4,  universal_integer  type  3.5.4,
  2179. universal type 4.10
  2180.  
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242. > 3.5.6  Real Types
  2243.  
  2244.  
  2245. Real types provide approximations to the real numbers, with relative bounds
  2246. on  errors  for  floating  point  types, and with absolute bounds for fixed
  2247. point types.
  2248.  
  2249.     real_type_definition ::=
  2250.        floating_point_constraint | fixed_point_constraint
  2251.  
  2252. A set of numbers called model numbers is associated with  each  real  type.
  2253. Error  bounds  on the predefined operations are given in terms of the model
  2254. numbers.  An implementation of the type must include at least  these  model
  2255. numbers and represent them exactly.
  2256.  
  2257. An  implementation-dependent  set  of  numbers, called the safe numbers, is
  2258. also associated with each real type.  The set of safe  numbers  of  a  real
  2259. type must include at least the set of model numbers of the type.  The range
  2260. of  safe  numbers  is allowed to be larger than the range of model numbers,
  2261. but error bounds on the predefined operations for safe numbers are given by
  2262. the same rules as  for  model  numbers.   Safe  numbers  therefore  provide
  2263. guaranteed error bounds for operations on an implementation-dependent range
  2264. of  numbers;   in  contrast, the range of model numbers depends only on the
  2265. real type definition and is therefore independent of the implementation.
  2266.  
  2267. Real literals are the literals of an anonymous predefined real type that is
  2268. called universal_real in this reference manual.  Other real types  have  no
  2269. literals.  However, for each real type, there exists an implicit conversion
  2270. that  converts  a  universal_real value into a value of the real type.  The
  2271. conditions under which these implicit conversions are invoked are described
  2272. in section 4.6.   If  the  universal_real  value  is  a  safe  number,  the
  2273. implicit conversion delivers the corresponding value;  if it belongs to the
  2274. range  of  safe  numbers but is not a safe number, then the converted value
  2275. can be any value within the range defined by the safe  numbers  next  above
  2276. and below the universal_real value.
  2277.  
  2278. The  execution of an operation that yields a value of a real type may raise
  2279. the exception NUMERIC_ERROR, as explained in section 4.5.7,  if  it  cannot
  2280. deliver a correct result (that is, if the value corresponding to one of the
  2281. possible  mathematical  results  does  not  belong  to  the  range  of safe
  2282. numbers);  in particular, this exception  can  be  raised  by  an  implicit
  2283. conversion.   However,  an  implementation  is  not  required  to raise the
  2284. exception NUMERIC_ERROR if the operation is part  of  a  larger  expression
  2285. whose result can be computed correctly (see 11.6).
  2286.  
  2287. The  elaboration  of a real type definition includes the elaboration of the
  2288. floating or fixed point constraint and creates a real type.
  2289.  
  2290. Note:
  2291.  
  2292. An algorithm written to rely only upon  the  minimum  numerical  properties
  2293. guaranteed  by  the  type  definition  for  model  numbers will be portable
  2294. without further precautions.
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307. References:  conversion 4.6, elaboration 3.9, fixed point constraint 3.5.9,
  2308. floating point constraint 3.5.7, literal 4.2, numeric_error exception 11.1,
  2309. predefined operation 3.3.3, real literal 2.4,  type  3.3,  type  definition
  2310. 3.3.1, universal type 4.10
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.  
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.  
  2334.  
  2335.  
  2336.  
  2337.  
  2338.  
  2339.  
  2340.  
  2341.  
  2342.  
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372. > 3.5.7  Floating Point Types
  2373.  
  2374.  
  2375. For  floating  point  types,  the  error  bound  is specified as a relative
  2376. precision by giving the required  minimum  number  of  significant  decimal
  2377. digits.
  2378.  
  2379.     floating_point_constraint ::=
  2380.        floating_accuracy_definition [range_constraint]
  2381.  
  2382.     floating_accuracy_definition ::=  digits static_simple_expression
  2383.  
  2384. The  minimum number of significant decimal digits is specified by the value
  2385. of the static simple expression of the floating accuracy definition.   This
  2386. value  must belong to some integer type and must be positive (nonzero);  it
  2387. is denoted by D in the remainder of this section.  If  the  floating  point
  2388. constraint  is  used  as  a  real  type  definition  and  includes  a range
  2389. constraint, then each bound of the  range  must  be  defined  by  a  static
  2390. expression  of  some  real  type, but the two bounds need not have the same
  2391. real type.
  2392.  
  2393. For a given radix, the following canonical form is defined for any floating
  2394. point model number other than zero:
  2395.  
  2396.     sign * mantissa * (radix ** exponent)
  2397.  
  2398. In this form: sign is either +1 or -1;  mantissa is expressed in  a  number
  2399. base  given by radix; and exponent is an integer number (possibly negative)
  2400. such that the integer part of mantissa is zero and the first digit  of  its
  2401. fractional part is not a zero.
  2402.  
  2403. The  specified  number  D  is the minimum number of decimal digits required
  2404. after the point in the decimal mantissa (that is, if radix  is  ten).   The
  2405. value  of D in turn determines a corresponding number B that is the minimum
  2406. number of binary digits required after the point  in  the  binary  mantissa
  2407. (that is, if radix is two).  The number B associated with D is the smallest
  2408. value  such  that the relative precision of the binary form is no less than
  2409. that specified for the decimal form.  (The number B  is  the  integer  next
  2410. above (D*log(10)/log(2)) + 1.)
  2411.  
  2412. The  model  numbers defined by a floating accuracy definition comprise zero
  2413. and all numbers whose binary canonical form has exactly B digits after  the
  2414. point  in  the  mantissa  and  an  exponent in the range -4*B .. +4*B.  The
  2415. guaranteed minimum accuracy of operations  of  a  floating  point  type  is
  2416. defined in terms of the model numbers of the floating point constraint that
  2417. forms the corresponding real type definition (see 4.5.7).
  2418.  
  2419. The   predefined   floating   point  types  include  the  type  FLOAT.   An
  2420. implementation may also have  predefined  types  such  as  SHORT_FLOAT  and
  2421. LONG_FLOAT,   which   have   (substantially)   less   and   more  accuracy,
  2422. respectively, than FLOAT.  The base type of each predefined floating  point
  2423. type  is  the  type  itself.  The model numbers of each predefined floating
  2424. point type are defined in terms of the number D of decimal digits  returned
  2425. by the attribute DIGITS (see 3.5.8).
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437. For  each  predefined  floating point type (consequently also for each type
  2438. derived therefrom), a set of safe numbers is defined as follows.  The  safe
  2439. numbers  have  the same number B of mantissa digits as the model numbers of
  2440. the type  and  have  an  exponent  in  the  range  -E  ..  +E  where  E  is
  2441. implementation-defined  and  at  least  equal  to the 4*B of model numbers.
  2442. (Consequently, the safe numbers include  the  model  numbers.)   The  rules
  2443. defining  the  accuracy of operations with model and safe numbers are given
  2444. in section 4.5.7.  The safe numbers of a subtype  are  those  of  its  base
  2445. type.
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502. A floating point type declaration of one of the two forms (that is, with or
  2503. without the optional range constraint indicated by the square brackets):
  2504.  
  2505.     type T is digits D [range L .. R];
  2506.  
  2507. is, by definition, equivalent to the following declarations:
  2508.  
  2509.     type floating_point_type is new predefined_floating_point_type;
  2510.     subtype T is floating_point_type digits D
  2511.        [range floating_point_type(L) .. floating_point_type(R)];
  2512.  
  2513. where  floating_point_type  is  an anonymous type, and where the predefined
  2514. floating point type is implicitly selected by the  implementation  so  that
  2515. its  model numbers include the model numbers defined by D;  furthermore, if
  2516. a range L .. R is supplied, then both L and R must belong to the  range  of
  2517. safe  numbers.   The  floating  point declaration is illegal if none of the
  2518. predefined floating point types  satisfies  these  requirements,  excepting
  2519. universal_real.   The  maximum  number of digits that can be specified in a
  2520. floating accuracy definition is given by the system-dependent named  number
  2521. SYSTEM.MAX_DIGITS (see 13.7.1).
  2522.  
  2523. The  elaboration  of  a  floating  point  type  declaration consists of the
  2524. elaboration of the equivalent type and subtype declarations.
  2525.  
  2526. If a floating point constraint follows a type mark in a subtype indication,
  2527. the type mark must denote a floating point type or subtype.   The  floating
  2528. point  constraint  is  compatible  with  the type mark only if the number D
  2529. specified in the floating accuracy  definition  is  not  greater  than  the
  2530. corresponding  number  D  for the type or subtype denoted by the type mark.
  2531. Furthermore, if the floating point constraint includes a range  constraint,
  2532. the  floating point constraint is compatible with the type mark only if the
  2533. range constraint is, itself, compatible with the type mark.
  2534.  
  2535. The elaboration of such a subtype indication includes  the  elaboration  of
  2536. the range constraint, if there is one;  it creates a floating point subtype
  2537. whose  model  numbers  are  defined  by the corresponding floating accuracy
  2538. definition.  A value of a floating point type belongs to a  floating  point
  2539. subtype if and only if it belongs to the range defined by the subtype.
  2540.  
  2541. The  same  arithmetic operators are predefined for all floating point types
  2542. (see 4.5).
  2543.  
  2544. Notes:
  2545.  
  2546. A range constraint is allowed  in  a  floating  point  subtype  indication,
  2547. either  directly  after  the  type  mark,  or  as  part of a floating point
  2548. constraint.  In either case the bounds of the range must belong to the base
  2549. type of the type mark (see  3.5).   The  imposition  of  a  floating  point
  2550. constraint on a type mark in a subtype indication cannot reduce the allowed
  2551. range  of  values unless it includes a range constraint (the range of model
  2552. numbers that correspond to the specified number of digits  can  be  smaller
  2553. than  the  range  of  numbers of the type mark).  A value that belongs to a
  2554. floating point subtype need not be a model number of the subtype.
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567. Examples:
  2568.  
  2569.     type COEFFICIENT is digits 10 range -1.0 .. 1.0;
  2570.  
  2571.     type REAL is digits 8;
  2572.     type MASS is digits 7 range 0.0 .. 1.0E35;
  2573.  
  2574.     subtype SHORT_COEFF is COEFFICIENT digits 5;    --   a subtype with less accuracy
  2575.     subtype PROBABILITY is REAL range 0.0 .. 1.0;   --   a subtype with a smaller range
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605.  
  2606.  
  2607.  
  2608.  
  2609.  
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632. Notes on the examples:
  2633.  
  2634. The implemented accuracy for COEFFICIENT  is  that  of  a  predefined  type
  2635. having  at least 10 digits of precision.  Consequently the specification of
  2636. 5 digits of precision for the subtype SHORT_COEFF is allowed.  The  largest
  2637. model number for the type MASS is approximately 1.27E30 and hence less than
  2638. the  specified  upper bound (1.0E35).  Consequently the declaration of this
  2639. type is legal only if this upper bound is in the range of the safe  numbers
  2640. of  a predefined floating point type having at least 7 digits of precision.
  2641.  
  2642. References:  anonymous type 3.3.1, arithmetic  operator  3.5.5  4.5,  based
  2643. literal  2.4.2,  belong  to a subtype 3.3, bound of a range 3.5, compatible
  2644. 3.3.2, derived type 3.4, digit 2.1, elaboration 3.1 3.9, error bound 3.5.6,
  2645. exponent 2.4.1 integer type  3.5.4,  model  number  3.5.6,  operation  3.3,
  2646. predefined operator 4.5, predefined type C, range constraint 3.5, real type
  2647. 3.5.6,  real  type  definition  3.5.6, safe number 3.5.6, simple expression
  2648. 4.4, static expression 4.9, subtype declaration 3.3.2,  subtype  indication
  2649. 3.3.2, subtype 3.3, type 3.3, type declaration 3.3.1, type mark 3.3.2
  2650.  
  2651.  
  2652.  
  2653. > 3.5.8  Operations of Floating Point Types
  2654.  
  2655.  
  2656. The  basic  operations  of  a  floating  point  type include the operations
  2657. involved in  assignment,  membership  tests,  qualification,  the  explicit
  2658. conversion of values of other numeric types to the floating point type, and
  2659. the  implicit  conversion of values of the type universal_real to the type.
  2660.  
  2661. In addition, for  every  floating  point  type  or  subtype  T,  the  basic
  2662. operations include the attributes listed below.  In this presentation, T is
  2663. referred  to  as  being  a  subtype  (the  subtype T) for any property that
  2664. depends on constraints imposed by T;  other properties are stated in  terms
  2665. of the base type of T.
  2666.  
  2667. The  first group of attributes yield characteristics of the subtype T.  The
  2668. attributes of this group are the attribute BASE (see 3.3.2), the attributes
  2669. FIRST and LAST (see 3.5), the representation attribute SIZE  (see  13.7.2),
  2670. and the following attributes:
  2671.  
  2672. T'DIGITS     Yields the number of decimal digits in the decimal mantissa of
  2673.              model  numbers  of  the subtype T.  (This attribute yields the
  2674.              number D of section 3.5.7.)  The value of this attribute is of
  2675.              the type universal_integer.
  2676.  
  2677. T'MANTISSA   Yields the number of binary digits in the binary  mantissa  of
  2678.              model  numbers  of  the subtype T.  (This attribute yields the
  2679.              number B of section 3.5.7.)  The value of this attribute is of
  2680.              the type universal_integer.
  2681.  
  2682. T'EPSILON    Yields the absolute value of the difference between the  model
  2683.              number 1.0 and the next model number above, for the subtype T.
  2684.              The value of this attribute is of the type universal_real.
  2685.  
  2686. T'EMAX       Yields the largest exponent value in the binary canonical form
  2687.              of model numbers of the subtype T.  (This attribute yields the
  2688.              product 4*B of section 3.5.7.)  The value of this attribute is
  2689.              of the type  universal_integer.
  2690.  
  2691. T'SMALL      Yields the smallest positive (nonzero)  model  number  of  the
  2692.              subtype  T.   The  value  of  this  attribute  is  of the type
  2693.              universal_real.
  2694.  
  2695. T'LARGE      Yields the largest positive model number  of  the  subtype  T.
  2696.              The value of this attribute is of the type universal_real.
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751. The  attributes  of the second group include the following attributes which
  2752. yield characteristics of the safe numbers:
  2753.  
  2754. T'SAFE_EMAX  Yields the largest exponent value in the binary canonical form
  2755.              of safe numbers of the base type of T.  (This attribute yields
  2756.              the number E of section 3.5.7.)  The value of  this  attribute
  2757.              is of the type universal_integer.
  2758.  
  2759. T'SAFE_SMALL Yields the smallest positive (nonzero) safe number of the base
  2760.              type  of  T.   The  value  of  this  attribute  is of the type
  2761.              universal_real.
  2762.  
  2763. T'SAFE_LARGE Yields the largest positive safe number of the base type of T.
  2764.              The value of this attribute is of the type universal_real.
  2765.  
  2766. In addition, the attributes A'SIZE and A'ADDRESS are defined for an  object
  2767. A  of a floating point type (see 13.7.2).  Finally, for each floating point
  2768. type there are machine-dependent attributes that are not related  to  model
  2769. numbers  and  safe  numbers.   They correspond to the attribute designators
  2770. MACHINE_RADIX,      MACHINE_MANTISSA,      MACHINE_EMAX,      MACHINE_EMIN,
  2771. MACHINE_ROUNDS, and MACHINE_OVERFLOWS (see 13.7.3).
  2772.  
  2773. Besides  the  basic  operations,  the  operations  of a floating point type
  2774. include the relational operators, and the following  predefined  arithmetic
  2775. operators:   the binary and unary adding operators - and +, the multiplying
  2776. operators * and /, the unary operator abs, and the exponentiating operator.
  2777.  
  2778. The operations of a subtype are the corresponding operations  of  the  type
  2779. except  for  the  following:   assignment, membership tests, qualification,
  2780. explicit conversion, and the attributes of the first group;  the effects of
  2781. these operations are redefined in terms of the subtype.
  2782.  
  2783. Notes:
  2784.  
  2785. The  attributes  EMAX,  SMALL,  LARGE,  and  EPSILON   are   provided   for
  2786. convenience.   They  are all related to MANTISSA by the following formulas:
  2787.  
  2788.     T'EMAX    = 4*T'MANTISSA
  2789.     T'EPSILON = 2.0**(1 - T'MANTISSA)
  2790.     T'SMALL   = 2.0**(-T'EMAX - 1)
  2791.     T'LARGE   = 2.0**T'EMAX * (1.0 - 2.0**(-T'MANTISSA))
  2792.  
  2793. The attribute MANTISSA, giving the number of binary digits in the mantissa,
  2794. is itself related to DIGITS.  The  following  relations  hold  between  the
  2795. characteristics of the model numbers and those of the safe numbers:
  2796.  
  2797.     T'BASE'EMAX  <= T'SAFE_EMAX
  2798.     T'BASE'SMALL >= T'SAFE_SMALL
  2799.     T'BASE'LARGE <= T'SAFE_LARGE
  2800.  
  2801. The attributes T'FIRST and T'LAST need not yield model or safe numbers.  If
  2802. a  certain  number  of  digits is specified in the declaration of a type or
  2803. subtype T, the attribute T'DIGITS yields this number.
  2804.  
  2805.  
  2806.  
  2807.  
  2808.  
  2809.  
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816. References:   abs  operator  4.5  4.5.6,  arithmetic  operator  3.5.5  4.5,
  2817. assignment  5.2,  attribute  4.1.4,  base  type 3.3, basic operation 3.3.3,
  2818. binary adding operator 4.5 4.5.3, bound of a  range  3.5,  constraint  3.3,
  2819. conversion  4.6,  digit  2.1,  exponentiating  operator 4.5 4.5.6, floating
  2820. point  type  3.5.7,  membership  test  4.5  4.5.2,  model   number   3.5.6,
  2821. multiplying  operator  4.5  4.5.5,  numeric type 3.5, object 3.2, operation
  2822. 3.3, predefined operator 4.5, qualified expression 4.7, relational operator
  2823. 4.5 4.5.2, safe number 3.5.6, subtype 3.3, type 3.3, unary adding  operator
  2824. 4.5   4.5.4,   universal   type   4.10,   universal_integer   type   3.5.4,
  2825. universal_real type 3.5.6
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845.  
  2846.  
  2847.  
  2848.  
  2849.  
  2850.  
  2851.  
  2852.  
  2853.  
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.  
  2872.  
  2873.  
  2874.  
  2875.  
  2876.  
  2877.  
  2878.  
  2879.  
  2880.  
  2881. > 3.5.9  Fixed Point Types
  2882.  
  2883.  
  2884. For fixed point types, the error bound is specified as an  absolute  value,
  2885. called the delta of the fixed point type.
  2886.  
  2887.     fixed_point_constraint ::=
  2888.        fixed_accuracy_definition [range_constraint]
  2889.  
  2890.     fixed_accuracy_definition ::=  delta static_simple_expression
  2891.  
  2892. The  delta is specified by the value of the static simple expression of the
  2893. fixed accuracy definition.  This value must belong to some  real  type  and
  2894. must  be  positive  (nonzero).   If the fixed point constraint is used as a
  2895. real type definition, then it must include a range constraint;  each  bound
  2896. of  the specified range must be defined by a static expression of some real
  2897. type but the two bounds need not have the same real  type.   If  the  fixed
  2898. point  constraint  is used in a subtype indication, the range constraint is
  2899. optional.
  2900.  
  2901. A canonical form is defined for any fixed point  model  number  other  than
  2902. zero.   In  this  form:   sign  is either +1 or -1;  mantissa is a positive
  2903. (nonzero) integer;  and any  model  number  is  a  multiple  of  a  certain
  2904. positive real number called small, as follows:
  2905.  
  2906.     sign * mantissa * small
  2907.  
  2908. For the model numbers defined by a fixed point constraint, the number small
  2909. is chosen as the largest power of two that is not greater than the delta of
  2910. the  fixed  accuracy  definition.  Alternatively, it is possible to specify
  2911. the value of small by a length clause  (see  13.2),  in  which  case  model
  2912. numbers  are  multiples  of  the  specified  value.  The guaranteed minimum
  2913. accuracy of operations of a fixed point type is defined  in  terms  of  the
  2914. model  numbers  of  the fixed point constraint that forms the corresponding
  2915. real type definition (see 4.5.7).
  2916.  
  2917. For a fixed point constraint that includes a range  constraint,  the  model
  2918. numbers  comprise  zero  and  all  multiples of small whose mantissa can be
  2919. expressed using exactly B binary digits, where the value of B is chosen  as
  2920. the  smallest integer number for which each bound of the specified range is
  2921. either a model number or lies at most small distant from  a  model  number.
  2922. For a fixed point constraint that does not include a range constraint (this
  2923. is  only  allowed  after  a  type mark, in a subtype indication), the model
  2924. numbers are defined by the delta of the fixed accuracy  definition  and  by
  2925. the range of the subtype denoted by the type mark.
  2926.  
  2927. An  implementation  must have at least one anonymous predefined fixed point
  2928. type.  The base type of each such fixed point type is the type itself.  The
  2929. model numbers of each predefined fixed point type  comprise  zero  and  all
  2930. numbers for which mantissa (in the canonical form) has the number of binary
  2931. digits  returned  by the attribute MANTISSA, and for which the number small
  2932. has the value returned by the attribute SMALL.
  2933.  
  2934. A fixed point type declaration of the form:
  2935.  
  2936.     type T is delta D range L .. R;
  2937.  
  2938. is, by definition, equivalent to the following declarations:
  2939.  
  2940.     type fixed_point_type is new predefined_fixed_point_type;
  2941.     subtype T is fixed_point_type
  2942.        range fixed_point_type(L) .. fixed_point_type(R);
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979.  
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.  
  2987.  
  2988.  
  2989.  
  2990.  
  2991.  
  2992.  
  2993.  
  2994.  
  2995.  
  2996.  
  2997.  
  2998.  
  2999.  
  3000.  
  3001. In these declarations, fixed_point_type  is  an  anonymous  type,  and  the
  3002. predefined fixed point type is implicitly selected by the implementation so
  3003. that its model numbers include the model numbers defined by the fixed point
  3004. constraint  (that  is,  by  D,  L,  and  R, and possibly by a length clause
  3005. specifying small).
  3006.  
  3007. The fixed point declaration is illegal  if  no  predefined  type  satisfies
  3008. these  requirements.   The safe numbers of a fixed point type are the model
  3009. numbers of its base type.
  3010.  
  3011. The  elaboration  of  a  fixed  point  type  declaration  consists  of  the
  3012. elaboration of the equivalent type and subtype declarations.
  3013.  
  3014. If  the fixed point constraint follows a type mark in a subtype indication,
  3015. the type mark must denote a fixed point type or subtype.  The  fixed  point
  3016. constraint  is compatible with the type mark only if the delta specified by
  3017. the fixed accuracy definition is not smaller than the delta for the type or
  3018. subtype denoted  by  the  type  mark.   Furthermore,  if  the  fixed  point
  3019. constraint  includes  a  range  constraint,  the  fixed point constraint is
  3020. compatible with the type mark only if  the  range  constraint  is,  itself,
  3021. compatible with the type mark.
  3022.  
  3023. The  elaboration  of  such a subtype indication includes the elaboration of
  3024. the range constraint, if there is one;  it creates a  fixed  point  subtype
  3025. whose model numbers are defined by the corresponding fixed point constraint
  3026. and  also  by the length clause specifying small, if there is one.  A value
  3027. of a fixed point type belongs to a fixed point subtype if and  only  if  it
  3028. belongs to the range defined by the subtype.
  3029.  
  3030. The same arithmetic operators are predefined for all fixed point types (see
  3031. 4.5).  Multiplication and division of fixed point values deliver results of
  3032. an  anonymous predefined fixed point type that is called universal_fixed in
  3033. this reference manual;  the accuracy of this type is arbitrarily fine.  The
  3034. values of this type must be converted explicitly to some numeric type.
  3035.  
  3036. Notes:
  3037.  
  3038. If S is a subtype of a fixed point type or subtype T, then the set of model
  3039. numbers of S is a subset of those of T.  If a length clause has been  given
  3040. for  T,  then both S and T have the same value for small.  Otherwise, since
  3041. small is a power of two, the small  of  S  is  equal  to  the  small  of  T
  3042. multiplied by a nonnegative power of two.
  3043.  
  3044. A  range  constraint is allowed in a fixed point subtype indication, either
  3045. directly after the type mark, or as part of a fixed point  constraint.   In
  3046. either  case  the  bounds  of the range must belong to the base type of the
  3047. type mark (see 3.5).
  3048.  
  3049. Examples:
  3050.  
  3051.     type VOLT is delta 0.125 range 0.0 .. 255.0;
  3052.     subtype ROUGH_VOLTAGE is VOLT delta 1.0;  --  same range as VOLT
  3053.  
  3054.     --  A pure fraction which requires all the available space in a word
  3055.     --  on a two's complement machine can be declared as the type FRACTION:
  3056.  
  3057.     DEL : constant := 1.0/2**(WORD_LENGTH - 1);
  3058.     type FRACTION is delta DEL range -1.0 .. 1.0 - DEL;
  3059.  
  3060. References:  anonymous type 3.3.1, arithmetic operator 3.5.5 4.5, base type
  3061. 3.3, belong to a subtype 3.3, bound  of  a  range  3.5,  compatible  3.3.2,
  3062. conversion  4.6,  elaboration  3.9,  error bound 3.5.6, length clause 13.2,
  3063. model number 3.5.6, numeric type 3.5, operation  3.3,  predefined  operator
  3064. 4.5,  range  constraint  3.5,  real type 3.5.6, real type definition 3.5.6,
  3065. safe number 3.5.6, simple expression 4.4, static  expression  4.9,  subtype
  3066. 3.3,  subtype  declaration  3.3.2, subtype indication 3.3.2, type 3.3, type
  3067. declaration 3.3.1, type mark 3.3.2
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122. > 3.5.10  Operations of Fixed Point Types
  3123.  
  3124.  
  3125. The basic operations of a fixed point type include the operations  involved
  3126. in  assignment, membership tests, qualification, the explicit conversion of
  3127. values of other numeric types to the fixed point  type,  and  the  implicit
  3128. conversion of values of the type universal_real to the type.
  3129.  
  3130. In  addition,  for every fixed point type or subtype T the basic operations
  3131. include the attributes listed below.  In this presentation T is referred to
  3132. as being a subtype (the  subtype  T)  for  any  property  that  depends  on
  3133. constraints imposed by T;  other properties are stated in terms of the base
  3134. type of T.
  3135.  
  3136. The  first group of attributes yield characteristics of the subtype T.  The
  3137. attributes  of  this  group  are  the  attributes  BASE  (see  3.3.2),  the
  3138. attributes FIRST and LAST (see 3.5), the representation attribute SIZE (see
  3139. 13.7.2) and the following attributes:
  3140.  
  3141. T'DELTA      Yields the value of the delta specified in the fixed  accuracy
  3142.              definition  for the subtype T.  The value of this attribute is
  3143.              of the type universal_real.
  3144.  
  3145. T'MANTISSA   Yields the number of binary digits in the  mantissa  of  model
  3146.              numbers of the subtype T.  (This attribute yields the number B
  3147.              of section 3.5.9.)  The value of this attribute is of the type
  3148.              universal_integer.
  3149.  
  3150. T'SMALL      Yields the smallest positive (nonzero)  model  number  of  the
  3151.              subtype  T.   The  value  of  this  attribute  is  of the type
  3152.              universal_real.
  3153.  
  3154. T'LARGE      Yields the largest positive model number  of  the  subtype  T.
  3155.              The value of this attribute is of the type universal_real.
  3156.  
  3157. T'FORE       Yields the minimum number of characters needed for the integer
  3158.              part of the decimal representation of any value of the subtype
  3159.              T,  assuming  that  the  representation  does  not  include an
  3160.              exponent, but includes a one-character prefix that is either a
  3161.              minus sign or a space.  (This minimum number does not  include
  3162.              superfluous  zeros  or  underlines, and is at least two.)  The
  3163.              value of this attribute is of the type universal_integer.
  3164.  
  3165. T'AFT        Yields the number of decimal digits needed after the point  to
  3166.              accommodate  the  precision of the subtype T, unless the delta
  3167.              of the subtype T is  greater  than  0.1,  in  which  case  the
  3168.              attribute  yields  the  value  one.   (T'AFT  is  the smallest
  3169.              positive integer N for which (10**N)*T'DELTA is  greater  than
  3170.              or  equal to one.)  The value of this attribute is of the type
  3171.              universal_integer.
  3172.  
  3173. The attributes of the second group include the following  attributes  which
  3174. yield characteristics of the safe numbers:
  3175.  
  3176. T'SAFE_SMALL Yields the smallest positive (nonzero) safe number of the base
  3177.              type  of  T.   The  value  of  this  attribute  is of the type
  3178.              universal_real.
  3179.  
  3180. T'SAFE_LARGE Yields the largest positive safe number of the base type of T.
  3181.              The value of this attribute is of the type universal_real.
  3182.  
  3183. In addition, the attributes A'SIZE and A'ADDRESS are defined for an  object
  3184. A  of  a fixed point type (see 13.7.2).  Finally, for each fixed point type
  3185. or subtype T, there are the machine-dependent  attributes  T'MACHINE_ROUNDS
  3186. and T'MACHINE_OVERFLOWS (see 13.7.3).
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202.  
  3203.  
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241. Besides  the basic operations, the operations of a fixed point type include
  3242. the  relational  operators,  and  the   following   predefined   arithmetic
  3243. operators:   the binary and unary adding operators - and +, the multiplying
  3244. operators * and /, and the operator abs.
  3245.  
  3246. The operations of a subtype are the corresponding operations  of  the  type
  3247. except  for  the  following:   assignment, membership tests, qualification,
  3248. explicit conversion, and the attributes of the first group;  the effects of
  3249. these operations are redefined in terms of the subtype.
  3250.  
  3251. Notes:
  3252.  
  3253. The value of the attribute T'FORE depends only on the range of the  subtype
  3254. T.   The value of the attribute T'AFT depends only on the value of T'DELTA.
  3255. The following relations exist between attributes of a fixed point type:
  3256.  
  3257.     T'LARGE      = (2**T'MANTISSA - 1) * T'SMALL
  3258.     T'SAFE_LARGE = T'BASE'LARGE
  3259.     T'SAFE_SMALL = T'BASE'SMALL
  3260.  
  3261. References:   abs  operator  4.5  4.5.6,  arithmetic  operator  3.5.5  4.5,
  3262. assignment  5.2,  base  type  3.3,  basic  operation  3.3.3,  binary adding
  3263. operator 4.5 4.5.3, bound of a range  3.5,  conversion  4.6,  delta  3.5.9,
  3264. fixed  point  type  3.5.9,  membership  test 4.5 4.5.2, model number 3.5.6,
  3265. multiplying operator 4.5 4.5.5, numeric type  3.5,  object  3.2,  operation
  3266. 3.3,  qualified  expression 4.7, relational operator 4.5 4.5.2, safe number
  3267. 3.5.6, subtype 3.3, unary adding operator 4.5 4.5.4, universal_integer type
  3268. 3.5.4, universal_real type 3.5.6
  3269.  
  3270.  
  3271.  
  3272. > 3.6  Array Types
  3273.  
  3274.  
  3275. An array object is a composite object consisting of  components  that  have
  3276. the  same  subtype.   The name for a component of an array uses one or more
  3277. index values belonging to specified discrete types.  The value of an  array
  3278. object is a composite value consisting of the values of its components.
  3279.  
  3280.     array_type_definition ::=
  3281.        unconstrained_array_definition | constrained_array_definition
  3282.  
  3283.     unconstrained_array_definition ::=
  3284.        array(index_subtype_definition {, index_subtype_definition}) of
  3285.                 component_subtype_indication
  3286.  
  3287.     constrained_array_definition ::=
  3288.        array index_constraint of component_subtype_indication
  3289.  
  3290.     index_subtype_definition ::= type_mark range <>
  3291.  
  3292.     index_constraint ::=  (discrete_range {, discrete_range})
  3293.  
  3294.     discrete_range ::= discrete_subtype_indication | range
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.  
  3305.  
  3306. An   array   object   is  characterized  by  the  number  of  indices  (the
  3307. dimensionality of the array), the type and  position  of  each  index,  the
  3308. lower and upper bounds for each index, and the type and possible constraint
  3309. of the components.  The order of the indices is significant.
  3310.  
  3311.  
  3312.  
  3313.  
  3314.  
  3315.  
  3316.  
  3317.  
  3318.  
  3319.  
  3320.  
  3321.  
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327.  
  3328.  
  3329.  
  3330.  
  3331.  
  3332.  
  3333.  
  3334.  
  3335.  
  3336.  
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.  
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.  
  3371. A  one-dimensional  array  has a distinct component for each possible index
  3372. value.  A multidimensional array has a distinct component for each possible
  3373. sequence of index values that can be formed by  selecting   one  value  for
  3374. each  index position (in the given order).  The possible values for a given
  3375. index are all the values between the lower  and  upper  bounds,  inclusive;
  3376. this range of values is called the index range.
  3377.  
  3378. An  unconstrained  array definition defines an array type.  For each object
  3379. that has the array type, the number of indices, the type  and  position  of
  3380. each  index,  and  the  subtype  of  the  components  are  as  in  the type
  3381. definition;  the values of the lower and upper bounds for each index belong
  3382. to the corresponding index subtype, except for null arrays as explained  in
  3383. section  3.6.1.   The  index  subtype  for  a  given  index position is, by
  3384. definition, the subtype denoted by the type mark of the corresponding index
  3385. subtype definition.  The compound delimiter <> (called a box) of  an  index
  3386. subtype  definition stands for an undefined range (different objects of the
  3387. type need not have the same bounds).  The elaboration of  an  unconstrained
  3388. array  definition creates an array type;  this elaboration includes that of
  3389. the component subtype indication.
  3390.  
  3391. A constrained array definition defines both an array type and a subtype  of
  3392. this type:
  3393.  
  3394.   -  The array type is an implicitly declared anonymous type;  this type is
  3395.      defined  by an (implicit) unconstrained array definition, in which the
  3396.      component  subtype  indication  is  that  of  the  constrained   array
  3397.      definition,  and  in  which  the  type  mark  of  each  index  subtype
  3398.      definition denotes the subtype defined by the  corresponding  discrete
  3399.      range.
  3400.  
  3401.   -  The array subtype is the subtype obtained by imposition of  the  index
  3402.      constraint on the array type.
  3403.  
  3404. If  a  constrained  array  definition  is given for a type declaration, the
  3405. simple name declared by this declaration denotes the array subtype.
  3406.  
  3407. The elaboration of a constrained array definition creates the corresponding
  3408. array type and array subtype.  For this elaboration, the  index  constraint
  3409. and  the  component  subtype  indication are elaborated.  The evaluation of
  3410. each discrete range of the index constraint  and  the  elaboration  of  the
  3411. component  subtype  indication  are  performed  in  some  order that is not
  3412. defined by the language.
  3413.  
  3414. Examples of type declarations with unconstrained array definitions:
  3415.  
  3416.     type VECTOR     is array(INTEGER  range <>) of REAL;
  3417.     type MATRIX     is array(INTEGER  range <>, INTEGER range <>) of REAL;
  3418.     type BIT_VECTOR is array(INTEGER  range <>) of BOOLEAN;
  3419.     type ROMAN      is array(POSITIVE range <>) of ROMAN_DIGIT;
  3420.  
  3421. Examples of type declarations with constrained array definitions:
  3422.  
  3423.     type TABLE    is array(1 .. 10) of INTEGER;
  3424.     type SCHEDULE is array(DAY) of BOOLEAN;
  3425.     type LINE     is array(1 .. MAX_LINE_SIZE) of CHARACTER;
  3426.  
  3427.  
  3428.  
  3429.  
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436. Examples of object declarations with constrained array definitions:
  3437.  
  3438.     GRID : array(1 .. 80, 1 .. 100) of BOOLEAN;
  3439.     MIX  : array(COLOR range RED .. GREEN) of BOOLEAN;
  3440.     PAGE : array(1 .. 50) of LINE;  --  an array of arrays
  3441.  
  3442.  
  3443.  
  3444.  
  3445.  
  3446.  
  3447.  
  3448.  
  3449.  
  3450.  
  3451.  
  3452.  
  3453.  
  3454.  
  3455.  
  3456.  
  3457.  
  3458.  
  3459.  
  3460.  
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.  
  3486.  
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.  
  3494.  
  3495.  
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501. Note:
  3502.  
  3503. For a one-dimensional array, the rule given means that a  type  declaration
  3504. with a constrained array definition such as
  3505.  
  3506.     type T is array(POSITIVE range MIN .. MAX) of COMPONENT;
  3507.  
  3508. is  equivalent  (in  the  absence  of an incorrect order dependence) to the
  3509. succession of declarations
  3510.  
  3511.     subtype INDEX_SUBTYPE is POSITIVE range MIN .. MAX;
  3512.     type ARRAY_TYPE is array(INDEX_SUBTYPE range <>) of COMPONENT;
  3513.     subtype T is ARRAY_TYPE(INDEX_SUBTYPE);
  3514.  
  3515. where index_subtype and array_type are both anonymous.  Consequently, T  is
  3516. the  name  of  a  subtype  and all objects declared with this type mark are
  3517. arrays that  have  the  same  bounds.   Similar  transformations  apply  to
  3518. multidimensional arrays.
  3519.  
  3520. A  similar transformation applies to an object whose declaration includes a
  3521. constrained array definition.  A consequence of this is that  no  two  such
  3522. objects have the same type.
  3523.  
  3524. References:   anonymous  type  3.3.1,  bound of a range 3.5, component 3.3,
  3525. constraint 3.3, discrete type 3.5, elaboration 3.1 3.9, in some order  1.6,
  3526. name  4.1,  object  3.2,  range 3.5, subtype 3.3, subtype indication 3.3.2,
  3527. type 3.3, type declaration 3.3.1, type definition 3.3.1, type mark 3.3.2
  3528.  
  3529.  
  3530.  
  3531. > 3.6.1  Index Constraints and Discrete Ranges
  3532.  
  3533.  
  3534. An index constraint determines the range of possible values for every index
  3535. of an array type, and thereby the corresponding array bounds.
  3536.  
  3537. For a discrete range used in a constrained array definition and defined  by
  3538. a  range,  an implicit conversion to the predefined type INTEGER is assumed
  3539. if each bound is either a numeric literal, a named number, or an attribute,
  3540. and the type of both bounds (prior to the implicit conversion) is the  type
  3541. universal_integer.   Otherwise,  both  bounds  must be of the same discrete
  3542. type,  other  than  universal_integer;   this  type  must  be  determinable
  3543. independently  of  the  context,  but  using the fact that the type must be
  3544. discrete and that both bounds must have the same type.  These  rules  apply
  3545. also  to  a  discrete  range  used in an iteration rule (see 5.5) or in the
  3546. declaration of a family of entries (see 9.5).
  3547.  
  3548. If an index constraint follows a type mark in a  subtype  indication,  then
  3549. the  type  or  subtype  denoted by the type mark must not already impose an
  3550. index constraint.  The type mark must denote either an unconstrained  array
  3551. type  or  an  access  type whose designated type is such an array type.  In
  3552. either case, the index constraint must provide a discrete  range  for  each
  3553. index  of  the  array  type and the type of each discrete range must be the
  3554. same as that of the corresponding index.
  3555.  
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566. An index constraint is compatible with the type denoted by the type mark if
  3567. and only if the constraint defined by each  discrete  range  is  compatible
  3568. with  the  corresponding  index  subtype.   If  any  of the discrete ranges
  3569. defines a null range, any array thus constrained is a null array, having no
  3570. components.  An array value satisfies an index constraint if at each  index
  3571. position  the  array  value  and  the  index constraint have the same index
  3572. bounds.  (Note,  however, that assignment and certain other  operations  on
  3573. arrays involve an implicit subtype conversion.)
  3574.  
  3575.  
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.  
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631. The bounds of each array object are determined as follows:
  3632.  
  3633.   -  For  a  variable  declared  by  an  object  declaration,  the  subtype
  3634.      indication  of  the  corresponding  object  declaration  must define a
  3635.      constrained array  subtype  (and,  thereby,  the  bounds).   The  same
  3636.      requirement   exists   for  the  subtype  indication  of  a  component
  3637.      declaration, if the type of the record component  is  an  array  type;
  3638.      and  for the component subtype indication of an array type definition,
  3639.      if the type of the array components is itself an array type.
  3640.  
  3641.   -  For a constant declared by an object declaration, the  bounds  of  the
  3642.      constant  are  defined  by  the  initial  value  if the subtype of the
  3643.      constant is unconstrained;  they are otherwise defined by this subtype
  3644.      (in the latter case, the initial value is the result  of  an  implicit
  3645.      subtype  conversion).   The  same  rule  applies  to  a generic formal
  3646.      parameter of mode in.
  3647.  
  3648.   -  For an array object designated by an access value, the bounds must  be
  3649.      defined  by  the  allocator  that  creates  the  array  object.   (The
  3650.      allocated object is constrained with the corresponding values  of  the
  3651.      bounds.)
  3652.  
  3653.   -  For a formal parameter of  a  subprogram  or  entry,  the  bounds  are
  3654.      obtained   from  the  corresponding  actual  parameter.   (The  formal
  3655.      parameter is constrained with the corresponding values of the bounds.)
  3656.  
  3657.   -  For a renaming declaration and for a generic formal parameter of  mode
  3658.      in  out,  the  bounds  are  those  of  the  renamed  object  or of the
  3659.      corresponding generic actual parameter.
  3660.  
  3661. For the elaboration  of  an  index  constraint,  the  discrete  ranges  are
  3662. evaluated in some order that is not defined by the language.
  3663.  
  3664. Examples of array declarations including an index constraint:
  3665.  
  3666.     BOARD     : MATRIX(1 .. 8,  1 .. 8);  --  see 3.6
  3667.     RECTANGLE : MATRIX(1 .. 20, 1 .. 30);
  3668.     INVERSE   : MATRIX(1 .. N,  1 .. N);  --  N need not be static
  3669.  
  3670.     FILTER    : BIT_VECTOR(0 .. 31);
  3671.  
  3672. Example of array declaration with a constrained array subtype:
  3673.  
  3674.     MY_SCHEDULE : SCHEDULE;  --  all arrays of type SCHEDULE have the same bounds
  3675.  
  3676. Example of record type with a component that is an array:
  3677.  
  3678.     type VAR_LINE(LENGTH : INTEGER) is
  3679.        record
  3680.           IMAGE : STRING(1 .. LENGTH);
  3681.        end record;
  3682.  
  3683.     NULL_LINE : VAR_LINE(0);  --  NULL_LINE.IMAGE is a null array
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.  
  3696. Notes:
  3697.  
  3698. The  elaboration of a subtype indication consisting of a type mark followed
  3699. by an index constraint checks the compatibility  of  the  index  constraint
  3700. with the type mark (see 3.3.2).
  3701.  
  3702. All  components  of  an array have the same subtype.  In particular, for an
  3703. array of components that are one-dimensional arrays, this  means  that  all
  3704. components have the same  bounds and hence the same length.
  3705.  
  3706.  
  3707.  
  3708.  
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  
  3720.  
  3721.  
  3722.  
  3723.  
  3724.  
  3725.  
  3726.  
  3727.  
  3728.  
  3729.  
  3730.  
  3731.  
  3732.  
  3733.  
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.  
  3741.  
  3742.  
  3743.  
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.  
  3754.  
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761. References:  access type 3.8, access type definition 3.8, access value 3.8,
  3762. actual  parameter  6.4.1,  allocator  4.8, array bound 3.6, array component
  3763. 3.6, array type 3.6, array type definition  3.6,  bound  of  a  range  3.5,
  3764. compatible  3.3.2,  component  declaration 3.7, constant 3.2.1, constrained
  3765. array definition  3.6,  constrained  array  subtype  3.6,  conversion  4.6,
  3766. designate  3.8,  designated  type 3.8, discrete range 3.6, entry 9.5, entry
  3767. family declaration 9.5, expression 4.4, formal parameter 6.1, function 6.5,
  3768. generic actual parameter 12.3, generic formal parameter 12.1 12.3,  generic
  3769. parameter  12.1,  index  3.6,  index  constraint  3.6.1, index subtype 3.6,
  3770. initial value 3.2.1, integer literal 2.4,  integer  type  3.5.4,  iteration
  3771. rule  5.5,  mode  12.1.1,  name  4.1,  null  range  3.5, object 3.2, object
  3772. declaration 3.2.1, predefined type C,  range  3.5,  record  component  3.7,
  3773. renaming  declaration  8.5,  result subtype 6.1, satisfy 3.3, subprogram 6,
  3774. subtype  conversion  4.6,  subtype  indication  3.3.2,  type  mark   3.3.2,
  3775. unconstrained  array  type  3.6,  unconstrained subtype 3.3, universal type
  3776. 4.10, universal_integer type 3.5.4, variable 3.2.1
  3777.  
  3778.  
  3779.  
  3780. > 3.6.2  Operations of Array Types
  3781.  
  3782.  
  3783. The basic operations of an array type include the  operations  involved  in
  3784. assignment  and  aggregates  (unless the array type is limited), membership
  3785. tests, indexed components, qualification,  and  explicit  conversion;   for
  3786. one-dimensional  arrays  the  basic  operations also include the operations
  3787. involved in slices, and also string literals if the  component  type  is  a
  3788. character type.
  3789.  
  3790. If  A  is  an array object, an array value, or a constrained array subtype,
  3791. the basic operations also  include  the  attributes  listed  below.   These
  3792. attributes are not allowed for an unconstrained array type.  The argument N
  3793. used  in  the attribute designators for the N-th dimension of an array must
  3794. be a static expression of type universal_integer.  The value of N  must  be
  3795. positive (nonzero) and no greater than the dimensionality of the array.
  3796.  
  3797. A'FIRST         Yields the lower bound of the first index range.  The value
  3798.                 of this attribute has the same type as this lower bound.
  3799.  
  3800. A'FIRST(N)      Yields the lower bound of the N-th index range.  The  value
  3801.                 of this attribute has the same type as this lower bound.
  3802.  
  3803. A'LAST          Yields the upper bound of the first index range.  The value
  3804.                 of this attribute has the same type as this upper bound.
  3805.  
  3806. A'LAST(N)       Yields the upper bound of the N-th index range.  The  value
  3807.                 of this attribute has the same type as this upper bound.
  3808.  
  3809. A'RANGE         Yields the first index range, that is, the range A'FIRST ..
  3810.                 A'LAST.
  3811.  
  3812. A'RANGE(N)      Yields the N-th index range, that is, the range  A'FIRST(N)
  3813.                 .. A'LAST(N).
  3814.  
  3815. A'LENGTH        Yields the number of values of the first index range  (zero
  3816.                 for  a  null range).  The value of this attribute is of the
  3817.                 type universal_integer.
  3818.  
  3819. A'LENGTH(N)     Yields the number of values of the N-th index  range  (zero
  3820.                 for  a  null range).  The value of this attribute is of the
  3821.                 type universal_integer.
  3822.  
  3823. In addition, the attribute T'BASE is defined for an array type or subtype T
  3824. (see 3.3.3);  the attribute T'SIZE is defined for an array type or  subtype
  3825. T,  and the attributes A'SIZE and A'ADDRESS are defined for an array object
  3826. A (see 13.7.2).
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.  
  3833.  
  3834.  
  3835.  
  3836.  
  3837.  
  3838.  
  3839.  
  3840.  
  3841.  
  3842.  
  3843.  
  3844.  
  3845.  
  3846.  
  3847.  
  3848.  
  3849.  
  3850.  
  3851.  
  3852.  
  3853.  
  3854.  
  3855.  
  3856.  
  3857.  
  3858.  
  3859.  
  3860.  
  3861.  
  3862.  
  3863.  
  3864.  
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880. Besides the basic operations, the operations of an array type  include  the
  3881. predefined comparison for equality and inequality, unless the array type is
  3882. limited.   For  one-dimensional  arrays, the operations include catenation,
  3883. unless the array type is limited;  if the  component  type  is  a  discrete
  3884. type,  the operations also include all predefined relational operators;  if
  3885. the component type is a boolean type, then the operations also include  the
  3886. unary logical negation operator not, and the logical operators.
  3887.  
  3888. Examples (using arrays declared in the examples of section 3.6.1):
  3889.  
  3890.     --  FILTER'FIRST       =    0   FILTER'LAST        =  31   FILTER'LENGTH  =  32
  3891.     --  RECTANGLE'LAST(1)  =   20   RECTANGLE'LAST(2)  =  30
  3892.  
  3893. Notes:
  3894.  
  3895. The  attributes  A'FIRST  and  A'FIRST(1)  yield the same value.  A similar
  3896. relation exists for the attributes  A'LAST,  A'RANGE,  and  A'LENGTH.   The
  3897. following  relations  are  satisfied (except for a null array) by the above
  3898. attributes if the index type is an integer type:
  3899.  
  3900.     A'LENGTH    = A'LAST    - A'FIRST    + 1
  3901.     A'LENGTH(N) = A'LAST(N) - A'FIRST(N) + 1
  3902.  
  3903. An array type is limited if its component type is limited (see 7.4.4).
  3904.  
  3905. References:  aggregate 4.3,  array  type  3.6,  assignment  5.2,  attribute
  3906. 4.1.4, basic operation 3.3.3, bound of a range 3.5, catenation operator 4.5
  3907. 4.5.3, character type 3.5.2, constrained array subtype 3.6, conversion 4.6,
  3908. designator  6.1, dimension 3.6, index 3.6, indexed component 4.1.1, limited
  3909. type 7.4.4, logical operator 4.5 4.5.1,  membership  test  4.5  4.5.2,  not
  3910. operator  4.5  4.5.6, null range 3.5, object 3.2, operation 3.3, predefined
  3911. operator 4.5, qualified expression  4.7,  relational  operator  4.5  4.5.2,
  3912. slice  4.1.2,  static expression 4.9, string literal 2.6, subcomponent 3.3,
  3913. type  3.3,   unconstrained   array   type   3.6,   universal   type   4.10,
  3914. universal_integer type 3.5.4
  3915.  
  3916.  
  3917.  
  3918. > 3.6.3  The Type String
  3919.  
  3920.  
  3921. The  values of the predefined type STRING are one-dimensional arrays of the
  3922. predefined type CHARACTER, indexed by  values  of  the  predefined  subtype
  3923. POSITIVE:
  3924.  
  3925.     subtype POSITIVE is INTEGER range 1 .. INTEGER'LAST;
  3926.     type STRING is array(POSITIVE range <>) of CHARACTER;
  3927.  
  3928. Examples:
  3929.  
  3930.     STARS      : STRING(1 .. 120) := (1 .. 120 => '*' );
  3931.     QUESTION   : constant STRING  := "HOW MANY CHARACTERS?";
  3932.     --  QUESTION'FIRST = 1, QUESTION'LAST = 20 (the number of characters)
  3933.     ASK_TWICE  : constant STRING  := QUESTION & QUESTION;
  3934.     NINETY_SIX : constant ROMAN   := "XCVI";        --  see 3.6
  3935.  
  3936. Notes:
  3937.  
  3938. String  literals  (see  2.6 and 4.2) are basic operations applicable to the
  3939. type STRING and to any other one-dimensional  array  type  whose  component
  3940. type is a character type.  The catenation operator is a predefined operator
  3941. for the type STRING and for one-dimensional array types;  it is represented
  3942. as  &.  The relational operators <, <=, >, and >= are defined for values of
  3943. these types, and correspond to lexicographic order (see 4.5.2).
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.  
  3965.  
  3966.  
  3967.  
  3968.  
  3969.  
  3970.  
  3971.  
  3972.  
  3973.  
  3974.  
  3975.  
  3976.  
  3977.  
  3978.  
  3979.  
  3980.  
  3981.  
  3982.  
  3983.  
  3984.  
  3985.  
  3986.  
  3987.  
  3988.  
  3989.  
  3990.  
  3991.  
  3992.  
  3993.  
  3994.  
  3995.  
  3996.  
  3997.  
  3998. References:  aggregate 4.3,  array  3.6,  catenation  operator  4.5  4.5.3,
  3999. character  type  3.5.2,  component  type  (of an array) 3.6, dimension 3.6,
  4000. index 3.6, lexicographic order 4.5.2, positional aggregate 4.3,  predefined
  4001. operator  4.5,  predefined  type  C,  relational operator 4.5 4.5.2, string
  4002. literal 2.6, subtype 3.3, type 3.3
  4003.  
  4004.  
  4005.  
  4006. > 3.7  Record Types
  4007.  
  4008.  
  4009. A record object is a composite object consisting of named components.   The
  4010. value  of  a record object is a composite value consisting of the values of
  4011. its components.
  4012.  
  4013.     record_type_definition ::=
  4014.        record
  4015.           component_list
  4016.        end record
  4017.  
  4018.     component_list ::=
  4019.           component_declaration {component_declaration}
  4020.        | {component_declaration} variant_part
  4021.        |  null;
  4022.  
  4023.     component_declaration ::=
  4024.        identifier_list : component_subtype_definition [:= expression];
  4025.  
  4026.     component_subtype_definition ::=  subtype_indication
  4027.  
  4028. Each component  declaration  declares  a  component  of  the  record  type.
  4029. Besides  components declared by component declarations, the components of a
  4030. record type include any components declared by discriminant  specifications
  4031. of  the  record  type  declaration.  The identifiers of all components of a
  4032. record type must be distinct.  The use of a  name  that  denotes  a  record
  4033. component  other  than a discriminant is not allowed within the record type
  4034. definition that declares the component.
  4035.  
  4036. A component  declaration  with  several  identifiers  is  equivalent  to  a
  4037. sequence  of  single  component  declarations, as explained in section 3.2.
  4038. Each single component declaration declares a record component whose subtype
  4039. is specified by the component subtype definition.
  4040.  
  4041. If a component  declaration  includes  the  assignment  compound  delimiter
  4042. followed  by an expression, the expression is the default expression of the
  4043. record component;  the default expression  must  be  of  the  type  of  the
  4044. component.   Default expressions are not allowed for components that are of
  4045. a limited type.
  4046.  
  4047. If a record type does not have a discriminant part, the same components are
  4048. present in all values of the type.  If the component list of a record  type
  4049. is  defined  by  the  reserved word null and there is no discriminant part,
  4050. then the record type has no components and all records of the type are null
  4051. records.
  4052.  
  4053.  
  4054.  
  4055.  
  4056.  
  4057.  
  4058.  
  4059.  
  4060.  
  4061.  
  4062.  
  4063. The elaboration of a record type definition  creates  a  record  type;   it
  4064. consists  of  the  elaboration  of  any  corresponding  (single)  component
  4065. declarations, in the order in which they appear,  including  any  component
  4066. declaration  in a variant part.  The elaboration of a component declaration
  4067. consists of the elaboration of the component subtype definition.
  4068.  
  4069. For the elaboration of a component subtype definition,  if  the  constraint
  4070. does  not depend on a discriminant (see 3.7.1), then the subtype indication
  4071. is elaborated.  If,  on  the  other  hand,  the  constraint  depends  on  a
  4072. discriminant,  then  the  elaboration  consists  of  the  evaluation of any
  4073. included expression that is not a discriminant.
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.  
  4111.  
  4112.  
  4113.  
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122.  
  4123.  
  4124.  
  4125.  
  4126.  
  4127.  
  4128. Examples of record type declarations:
  4129.  
  4130.     type DATE is
  4131.        record
  4132.           DAY   : INTEGER range 1 .. 31;
  4133.           MONTH : MONTH_NAME;
  4134.           YEAR  : INTEGER range 0 .. 4000;
  4135.        end record;
  4136.  
  4137.     type COMPLEX is
  4138.        record
  4139.           RE : REAL := 0.0;
  4140.           IM : REAL := 0.0;
  4141.        end record;
  4142.  
  4143. Examples of record variables:
  4144.  
  4145.     TOMORROW, YESTERDAY : DATE;
  4146.     A, B, C : COMPLEX;
  4147.  
  4148.     -- both components of A, B, and C are implicitly initialized to zero
  4149.  
  4150. Notes:
  4151.  
  4152. The default expression of a record component is implicitly evaluated by the
  4153. elaboration of the declaration of a record object, in  the  absence  of  an
  4154. explicit  initialization  (see  3.2.1).   If  a  component  declaration has
  4155. several identifiers,  the  expression  is  evaluated  once  for  each  such
  4156. component  of the object (since the declaration is equivalent to a sequence
  4157. of single component declarations).
  4158.  
  4159. Unlike the components of an array, the components of a record need  not  be
  4160. of the same type.
  4161.  
  4162. References:   assignment  compound  delimiter 2.2, component 3.3, composite
  4163. value 3.3, constraint 3.3, declaration 3.1, depend on a discriminant 3.7.1,
  4164. discriminant 3.3, discriminant part 3.7 3.7.1, elaboration 3.9,  expression
  4165. 4.4,  identifier  2.3,  identifier  list 3.2, limited type 7.4.4, name 4.1,
  4166. object 3.2, subtype 3.3, type 3.3, type mark 3.3.2, variant part 3.7.3
  4167.  
  4168.  
  4169.  
  4170. > 3.7.1  Discriminants
  4171.  
  4172.  
  4173. A discriminant part specifies the discriminants of a type.  A  discriminant
  4174. of  a record is a component of the record.  The type of a discriminant must
  4175. be discrete.
  4176.  
  4177.     discriminant_part ::=
  4178.        (discriminant_specification {; discriminant_specification})
  4179.  
  4180.     discriminant_specification ::=
  4181.        identifier_list : type_mark [:= expression]
  4182.  
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188.  
  4189.  
  4190.  
  4191.  
  4192.  
  4193. A discriminant part is only allowed in the type declaration  for  a  record
  4194. type,  in a private type declaration or an incomplete type declaration (the
  4195. corresponding full declaration must then declare a record type), and in the
  4196. generic parameter declaration for a formal private type.
  4197.  
  4198.  
  4199.  
  4200.  
  4201.  
  4202.  
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.  
  4212.  
  4213.  
  4214.  
  4215.  
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.  
  4222.  
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228.  
  4229.  
  4230.  
  4231.  
  4232.  
  4233.  
  4234.  
  4235.  
  4236.  
  4237.  
  4238.  
  4239.  
  4240.  
  4241.  
  4242.  
  4243.  
  4244.  
  4245.  
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.  
  4252.  
  4253.  
  4254.  
  4255.  
  4256.  
  4257.  
  4258. A discriminant specification with several identifiers is  equivalent  to  a
  4259. sequence  of  single  discriminant  specifications, as explained in section
  4260. 3.2.  Each single discriminant specification declares a discriminant.  If a
  4261. discriminant  specification  includes  the  assignment  compound  delimiter
  4262. followed  by an expression, the expression is the default expression of the
  4263. discriminant;   the  default  expression  must  be  of  the  type  of   the
  4264. discriminant.   Default  expressions must be provided either for all or for
  4265. none of the discriminants of a discriminant part.
  4266.  
  4267. The use of the name of a discriminant is not allowed in default expressions
  4268. of a discriminant part if the specification of the discriminant  is  itself
  4269. given in the discriminant part.
  4270.  
  4271. Within  a  record  type  definition  the only allowed uses of the name of a
  4272. discriminant of the record type are:  in the default expressions for record
  4273. components;  in a  variant  part  as  the  discriminant  name;   and  in  a
  4274. component  subtype definition, either as a bound in an index constraint, or
  4275. to  specify  a  discriminant  value  in  a  discriminant   constraint.    A
  4276. discriminant  name  used in these component subtype definitions must appear
  4277. by itself, not as part of a  larger  expression.   Such  component  subtype
  4278. definitions and such constraints are said to depend on a discriminant.
  4279.  
  4280. A component is said to depend on a discriminant if it is a record component
  4281. declared  in  a variant part, or a record component whose component subtype
  4282. definition depends on a discriminant, or finally, one of the  subcomponents
  4283. of a component that itself depends on a discriminant.
  4284.  
  4285. Each  record value includes a value for each discriminant specified for the
  4286. record type;  it also includes a value for each record component that  does
  4287. not  depend  on  a discriminant.  The values of the discriminants determine
  4288. which other component values are in the record value.
  4289.  
  4290. Direct  assignment  to  a  discriminant  of  an  object  is  not   allowed;
  4291. furthermore a discriminant is not allowed as an actual parameter of mode in
  4292. out  or  out,  or  as  a generic actual parameter of mode in out.  The only
  4293. allowed way to change the value of a  discriminant  of  a  variable  is  to
  4294. assign a (complete) value to the variable itself.  Similarly, an assignment
  4295. to  the variable itself is the only allowed way to change the constraint of
  4296. one of its components, if the component subtype  definition  depends  on  a
  4297. discriminant of the variable.
  4298.  
  4299. The elaboration of a discriminant part has no other effect.
  4300.  
  4301. Examples:
  4302.  
  4303.     type BUFFER(SIZE : BUFFER_SIZE := 100) is        -- see 3.5.4
  4304.        record
  4305.           POS   : BUFFER_SIZE := 0;
  4306.           VALUE : STRING(1 .. SIZE);
  4307.        end record;
  4308.  
  4309.     type SQUARE(SIDE : INTEGER) is
  4310.        record
  4311.           MAT : MATRIX(1 .. SIDE, 1 .. SIDE);       -- see 3.6
  4312.        end record;
  4313.  
  4314.     type DOUBLE_SQUARE(NUMBER : INTEGER) is
  4315.        record
  4316.           LEFT  : SQUARE(NUMBER);
  4317.           RIGHT : SQUARE(NUMBER);
  4318.        end record;
  4319.  
  4320.     type ITEM(NUMBER : POSITIVE) is
  4321.        record
  4322.           CONTENT : INTEGER;
  4323.           --  no component depends on the discriminant
  4324.        end record;
  4325.  
  4326. References:   assignment 5.2, assignment compound delimiter 2.2, bound of a
  4327. range 3.5, component 3.3, component declaration 3.7, component of a  record
  4328. 3.7,  declaration  3.1,  discrete  type 3.5, discriminant 3.3, discriminant
  4329. constraint 3.7.2, elaboration 3.9,  expression  4.4,  generic  formal  type
  4330. 12.1,  generic  parameter declaration 12.1, identifier 2.3, identifier list
  4331. 3.2, incomplete type declaration 3.8.1, index constraint 3.6.1,  name  4.1,
  4332. object  3.2,  private  type  7.4, private type declaration 7.4, record type
  4333. 3.7, scope 8.2, simple  name  4.1,  subcomponent  3.3,  subtype  indication
  4334. 3.3.2, type declaration 3.3.1, type mark 3.3.2, variant part 3.7.3
  4335.  
  4336.  
  4337.  
  4338.  
  4339. > 3.7.2  Discriminant Constraints
  4340.  
  4341.  
  4342. A  discriminant constraint is only allowed in a subtype indication, after a
  4343. type mark.  This type mark must denote either a type with discriminants, or
  4344. an access type whose designated type  is  a  type  with  discriminants.   A
  4345. discriminant constraint specifies the values of these discriminants.
  4346.  
  4347.     discriminant_constraint ::=
  4348.        (discriminant_association {, discriminant_association})
  4349.  
  4350.     discriminant_association ::=
  4351.        [discriminant_simple_name {| discriminant_simple_name} =>] expression
  4352.  
  4353. Each  discriminant  association  associates  an expression with one or more
  4354. discriminants.  A discriminant association is  said  to  be  named  if  the
  4355. discriminants  are  specified  explicitly  by their names;  it is otherwise
  4356. said  to  be  positional.   For  a  positional  association,  the  (single)
  4357. discriminant  is implicitly specified by position, in textual order.  Named
  4358. associations can be given in any order, but if both  positional  and  named
  4359. associations  are used in the same discriminant constraint, then positional
  4360. associations must occur first, at their  normal  position.   Hence  once  a
  4361. named association is used, the rest of the discriminant constraint must use
  4362. only named associations.
  4363.  
  4364. For  a  named  discriminant association, the discriminant names must denote
  4365. discriminants of the type for which the discriminant constraint  is  given.
  4366. A  discriminant  association  with  more than one discriminant name is only
  4367. allowed if the named discriminants are all of the same type.   Furthermore,
  4368. for  each  discriminant  association  (whether  named  or  positional), the
  4369. expression and the associated discriminants must have  the  same  type.   A
  4370. discriminant   constraint   must   provide   exactly  one  value  for  each
  4371. discriminant of the type.
  4372.  
  4373. A discriminant constraint is compatible with the type  denoted  by  a  type
  4374. mark,  if and only if each discriminant value belongs to the subtype of the
  4375. corresponding discriminant.   In  addition,  for  each  subcomponent  whose
  4376. component   subtype   specification   depends   on    a  discriminant,  the
  4377. discriminant value is substituted for the discriminant  in  this  component
  4378. subtype  specification  and  the  compatibility  of  the  resulting subtype
  4379. indication is checked.
  4380.  
  4381. A composite value satisfies a discriminant constraint if and only  if  each
  4382. discriminant   of  the  composite  value  has  the  value  imposed  by  the
  4383. discriminant constraint.
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.  
  4427.  
  4428.  
  4429.  
  4430.  
  4431.  
  4432.  
  4433.  
  4434.  
  4435.  
  4436.  
  4437.  
  4438.  
  4439.  
  4440. The initial values of the  discriminants  of  an  object  of  a  type  with
  4441. discriminants are determined as follows:
  4442.  
  4443.   -  For  a  variable  declared  by  an  object  declaration,  the  subtype
  4444.      indication  of  the  corresponding  object  declaration  must impose a
  4445.      discriminant constraint  unless  default  expressions  exist  for  the
  4446.      discriminants;   the  discriminant  values  are  defined either by the
  4447.      constraint or, in its absence, by the default expressions.   The  same
  4448.      requirement   exists   for  the  subtype  indication  of  a  component
  4449.      declaration, if the type of the record  component  has  discriminants;
  4450.      and for the component subtype indication of an array type, if the type
  4451.      of the array components is a type with discriminants.
  4452.  
  4453.   -  For a constant declared by an object declaration, the  values  of  the
  4454.      discriminants  are  those  of  the initial value if the subtype of the
  4455.      constant is unconstrained;  they are otherwise defined by this subtype
  4456.      (in the latter case, an exception is raised if the initial value  does
  4457.      not  belong  to  this  subtype).   The  same rule applies to a generic
  4458.      parameter of mode in.
  4459.  
  4460.   -  For an object designated by an access value, the  discriminant  values
  4461.      must  be  defined  by  the  allocator  that  creates the object.  (The
  4462.      allocated object is constrained with  the  corresponding  discriminant
  4463.      values.)
  4464.  
  4465.   -  For a formal parameter of a subprogram or entry, the discriminants  of
  4466.      the  formal  parameter are initialized with those of the corresponding
  4467.      actual  parameter.   (The  formal  parameter  is  constrained  if  the
  4468.      corresponding  actual parameter is constrained, and in any case if the
  4469.      mode is in or if the subtype of the formal parameter is  constrained.)
  4470.  
  4471.   -  For a renaming declaration and for a generic formal parameter of  mode
  4472.      in  out,  the  discriminants are those of the renamed object or of the
  4473.      corresponding generic actual parameter.
  4474.  
  4475. For the elaboration of a discriminant constraint, the expressions given  in
  4476. the  discriminant  associations  are  evaluated  in  some order that is not
  4477. defined by  the  language;   the  expression  of  a  named  association  is
  4478. evaluated once for each named discriminant.
  4479.  
  4480. Examples (using types declared in the previous section):
  4481.  
  4482.     LARGE   : BUFFER(200);  --  constrained, always 200 characters (explicit discriminant value)
  4483.     MESSAGE : BUFFER;       --  unconstrained, initially 100 characters (default discriminant value)
  4484.  
  4485.     BASIS   : SQUARE(5);    --  constrained, always 5 by 5
  4486.     ILLEGAL : SQUARE;       --  illegal, a SQUARE must be constrained
  4487.  
  4488. Note:
  4489.  
  4490. The  above  rules  and  the  rules  defining  the  elaboration of an object
  4491. declaration (see 3.2) ensure that discriminants always have  a  value.   In
  4492. particular,   if   a  discriminant  constraint  is  imposed  on  an  object
  4493. declaration, each discriminant is initialized with the value  specified  by
  4494. the   constraint.    Similarly,  if  the  subtype  of  a  component  has  a
  4495. discriminant  constraint,  the   discriminants   of   the   component   are
  4496. correspondingly initialized.
  4497.  
  4498. References:  access type 3.8, access type definition 3.8, access value 3.8,
  4499. actual  parameter 6.4.1, allocator 4.8, array type definition 3.6, bound of
  4500. a range 3.5, compatible 3.3.2, component 3.3,  component  declaration  3.7,
  4501. component  subtype  indication  3.7,  composite  value 3.3, constant 3.2.1,
  4502. constrained  subtype  3.3,  constraint  3.3,   declaration   3.1,   default
  4503. expression  for  a  discriminant  3.7,  depend  on  a  discriminant  3.7.1,
  4504. designate 3.8, designated type  3.8,  discriminant  3.3,  elaboration  3.9,
  4505. entry  9.5,  evaluation  4.5, expression 4.4, formal parameter 6.1, generic
  4506. actual parameter 12.3, generic formal parameter 12.1  12.3,  mode  in  6.1,
  4507. mode  in  out 6.1, name 4.1, object 3.2, object declaration 3.2.1, renaming
  4508. declaration  8.5,  reserved  word  2.9,  satisfy  3.3,  simple  name   4.1,
  4509. subcomponent 3.3, subprogram 6, subtype 3.3, subtype indication 3.3.2, type
  4510. 3.3, type mark 3.3.2, variable 3.2.1
  4511.  
  4512.  
  4513.  
  4514.  
  4515.  
  4516.  
  4517.  
  4518.  
  4519.  
  4520.  
  4521.  
  4522.  
  4523.  
  4524.  
  4525.  
  4526.  
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  
  4536.  
  4537.  
  4538.  
  4539.  
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.  
  4546.  
  4547.  
  4548.  
  4549.  
  4550.  
  4551.  
  4552.  
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558.  
  4559.  
  4560. > 3.7.3  Variant Parts
  4561.  
  4562.  
  4563. A   record  type  with  a  variant  part  specifies  alternative  lists  of
  4564. components.  Each variant defines  the  components  for  the  corresponding
  4565. value or values of the discriminant.
  4566.  
  4567.     variant_part ::=
  4568.        case discriminant_simple_name is
  4569.            variant
  4570.           {variant}
  4571.        end case;
  4572.  
  4573.     variant ::=
  4574.        when choice {| choice} =>
  4575.           component_list
  4576.  
  4577.     choice ::= simple_expression
  4578.        | discrete_range | others | component_simple_name
  4579.  
  4580. Each  variant  starts with a list of choices which must be of the same type
  4581. as the discriminant of the variant part.  The type of the discriminant of a
  4582. variant part must not be a generic formal type.   If  the  subtype  of  the
  4583. discriminant is static, then each value of this subtype must be represented
  4584. once  and only once in the set of choices of the variant part, and no other
  4585. value is allowed.   Otherwise,  each  value  of  the  (base)  type  of  the
  4586. discriminant  must be represented once and only once in the set of choices.
  4587.  
  4588. The simple expressions and discrete ranges given as choices  in  a  variant
  4589. part  must  be static.  A choice defined by a discrete range stands for all
  4590. values in the corresponding range (none  if  a  null  range).   The  choice
  4591. others  is  only  allowed  for the last variant and as its only choice;  it
  4592. stands for all values (possibly none) not given in the choices of  previous
  4593. variants.   A component simple name is not allowed as a choice of a variant
  4594. (although it is part of the syntax of choice).
  4595.  
  4596. A record value contains the values of the components of a given variant  if
  4597. and  only if the discriminant value is equal to one of the values specified
  4598. by the choices of the variant.  This rule applies in turn  to  any  further
  4599. variant  that  is,  itself,  included  in  the  component list of the given
  4600. variant.  If the component list of a variant  is  specified  by  null,  the
  4601. variant has no components.
  4602.  
  4603. Example of record type with a variant part:
  4604.  
  4605.     type DEVICE is (PRINTER, DISK, DRUM);
  4606.     type STATE  is (OPEN, CLOSED);
  4607.  
  4608.     type PERIPHERAL(UNIT : DEVICE := DISK) is
  4609.        record
  4610.           STATUS : STATE;
  4611.           case UNIT is
  4612.              when PRINTER =>
  4613.                 LINE_COUNT : INTEGER range 1 .. PAGE_SIZE;
  4614.              when others =>
  4615.                 CYLINDER   : CYLINDER_INDEX;
  4616.                 TRACK      : TRACK_NUMBER;
  4617.           end case;
  4618.        end record;
  4619.  
  4620.  
  4621.  
  4622.  
  4623.  
  4624.  
  4625.  
  4626.  
  4627.  
  4628.  
  4629.  
  4630.  
  4631.  
  4632.  
  4633.  
  4634.  
  4635.  
  4636.  
  4637.  
  4638.  
  4639.  
  4640.  
  4641.  
  4642.  
  4643.  
  4644.  
  4645.  
  4646.  
  4647.  
  4648.  
  4649.  
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.  
  4680. Examples of record subtypes:
  4681.  
  4682.     subtype DRUM_UNIT is PERIPHERAL(DRUM);
  4683.     subtype DISK_UNIT is PERIPHERAL(DISK);
  4684.  
  4685. Examples of constrained record variables:
  4686.  
  4687.     WRITER  : PERIPHERAL(UNIT => PRINTER);
  4688.     ARCHIVE : DISK_UNIT;
  4689.  
  4690. Note:
  4691.  
  4692. Choices  with discrete values are also used in case statements and in array
  4693. aggregates.  Choices  with  component  simple  names  are  used  in  record
  4694. aggregates.
  4695.  
  4696. References:  array aggregate 4.3.2, base type 3.3, component 3.3, component
  4697. list 3.7, discrete range 3.6, discriminant 3.3, generic formal type 12.1.2,
  4698. null  range 3.5, record aggregate 4.3.1, range 3.5, record type 3.7, simple
  4699. expression  4.4,  simple  name  4.1,  static  discrete  range  4.9,  static
  4700. expression 4.9, static subtype 4.9, subtype 3.3
  4701.  
  4702.  
  4703.  
  4704.  
  4705. > 3.7.4  Operations of Record Types
  4706.  
  4707.  
  4708. The  basic  operations  of a record type include the operations involved in
  4709. assignment and aggregates (unless the type is limited),  membership  tests,
  4710. selection  of  record  components,  qualification, and type conversion (for
  4711. derived types).
  4712.  
  4713. For any object A of a type with discriminants, the  basic  operations  also
  4714. include the following attribute:
  4715.  
  4716. A'CONSTRAINED   Yields the value TRUE if a discriminant constraint  applies
  4717.                 to  the object A, or if the object is a constant (including
  4718.                 a formal parameter or generic formal parameter of mode in);
  4719.                 yields the value FALSE otherwise.  If A is a generic formal
  4720.                 parameter of mode in out, or if A is a formal parameter  of
  4721.                 mode  in  out  or  out  and  the  type  mark  given  in the
  4722.                 corresponding   parameter    specification    denotes    an
  4723.                 unconstrained  type  with  discriminants, then the value of
  4724.                 this attribute is obtained from that of  the  corresponding
  4725.                 actual  parameter.   The  value of this attribute is of the
  4726.                 predefined type BOOLEAN.
  4727.  
  4728. In addition, the attributes T'BASE and T'SIZE are defined for a record type
  4729. or subtype T (see 3.3.3);  the attributes A'SIZE and A'ADDRESS are  defined
  4730. for a record object A (see 13.7.2).
  4731.  
  4732. Besides  the  basic operations, the operations of a record type include the
  4733. predefined comparison for equality  and  inequality,  unless  the  type  is
  4734. limited.
  4735.  
  4736.  
  4737.  
  4738.  
  4739.  
  4740.  
  4741.  
  4742.  
  4743.  
  4744.  
  4745. Note:
  4746.  
  4747. A  record  type  is limited if the type of any of its components is limited
  4748. (see 7.4.4).
  4749.  
  4750. References:   actual  parameter  6.4.1,  aggregate  4.3,  assignment   5.2,
  4751. attribute 4.1.4, basic operation 3.3.3, boolean type 3.5.3, constant 3.2.1,
  4752. conversion 4.6, derived type 3.4, discriminant 3.3, discriminant constraint
  4753. 3.7.2,  formal parameter 6.1, generic actual parameter 12.3, generic formal
  4754. parameter 12.1 12.3, limited type 7.4.4, membership test  4.5  4.5.2,  mode
  4755. 6.1,  object 3.2.1, operation 3.3, predefined operator 4.5, predefined type
  4756. C, qualified expression 4.7,  record  type  3.7,  relational  operator  4.5
  4757. 4.5.2, selected component 4.1.3, subcomponent 3.3, subtype 3.3, type 3.3
  4758.  
  4759.  
  4760.  
  4761.  
  4762.  
  4763.  
  4764.  
  4765.  
  4766.  
  4767.  
  4768.  
  4769.  
  4770.  
  4771.  
  4772.  
  4773.  
  4774.  
  4775.  
  4776.  
  4777.  
  4778.  
  4779.  
  4780.  
  4781.  
  4782.  
  4783.  
  4784.  
  4785.  
  4786.  
  4787.  
  4788.  
  4789.  
  4790.  
  4791.  
  4792.  
  4793.  
  4794.  
  4795.  
  4796.  
  4797.  
  4798.  
  4799.  
  4800.  
  4801.  
  4802.  
  4803.  
  4804.  
  4805.  
  4806.  
  4807.  
  4808.  
  4809.  
  4810. > 3.8  Access Types
  4811.  
  4812.  
  4813. An  object  declared by an object declaration is created by the elaboration
  4814. of the object declaration and is denoted by a simple name or by some  other
  4815. form  of  name.   In  contrast,  there  are objects that are created by the
  4816. evaluation of allocators (see 4.8) and that have no simple name.  Access to
  4817. such an object is achieved by an access value  returned  by  an  allocator;
  4818. the access value is said to designate the object.
  4819.  
  4820.     access_type_definition ::= access subtype_indication
  4821.  
  4822. For each access type, there is a literal null which has a null access value
  4823. designating  no  object  at  all.   The null value of an access type is the
  4824. default initial value of the type.  Other values  of  an  access  type  are
  4825. obtained  by  evaluation  of  a  special  operation  of the type, called an
  4826. allocator.  Each such access value designates  an  object  of  the  subtype
  4827. defined  by  the  subtype  indication  of the access type definition;  this
  4828. subtype is called the designated subtype;  the base type of this subtype is
  4829. called the designated type.  The objects designated by  the  values  of  an
  4830. access type form a collection implicitly associated with the type.
  4831.  
  4832. The elaboration of an access type definition consists of the elaboration of
  4833. the subtype indication and creates an access type.
  4834.  
  4835. If  an  access  object  is  constant,  the contained access value cannot be
  4836. changed and always designates the same object.   On  the  other  hand,  the
  4837. value  of the designated object need not remain the same (assignment to the
  4838. designated object is allowed unless the designated type is limited).
  4839.  
  4840. The only forms of constraint that are allowed after the name of  an  access
  4841. type  in  a  subtype  indication  are  index  constraints  and discriminant
  4842. constraints.  (See sections 3.6.1 and 3.7.2 for  the  rules  applicable  to
  4843. these  subtype  indications.)   An  access value belongs to a corresponding
  4844. subtype of an access type either if the access value is the null  value  or
  4845. if the value of the designated object satisfies the constraint.
  4846.  
  4847. Examples:
  4848.  
  4849.     type FRAME is access MATRIX;        --  see 3.6
  4850.  
  4851.     type BUFFER_NAME is access BUFFER;  --  see 3.7.1
  4852.  
  4853. Notes:
  4854.  
  4855. An access value delivered by an allocator can be assigned to several access
  4856. objects.   Hence it is possible for an object created by an allocator to be
  4857. designated by more than one variable or constant of the  access  type.   An
  4858. access  value  can  only  designate  an object created by an allocator;  in
  4859. particular,  it  cannot  designate  an  object  declared   by   an   object
  4860. declaration.
  4861.  
  4862. If the type of the objects designated by the access values is an array type
  4863. or a type with discriminants, these objects are constrained with either the
  4864. array  bounds  or the discriminant values supplied implicitly or explicitly
  4865. for the corresponding allocators (see 4.8).
  4866.  
  4867. Access values are called pointers or references in some other languages.
  4868.  
  4869. References:  allocator 4.8, array type 3.6, assignment  5.2,  belong  to  a
  4870. subtype 3.3, constant 3.2.1, constraint 3.3, discriminant constraint 3.7.2,
  4871. elaboration  3.9,  index constraint 3.6.1, index specification 3.6, limited
  4872. type 7.4.4, literal 4.2, name 4.1, object 3.2.1, object declaration  3.2.1,
  4873. reserved  word 2.9, satisfy 3.3, simple name 4.1, subcomponent 3.3, subtype
  4874. 3.3, subtype indication 3.3.2, type 3.3, variable 3.2.1
  4875.  
  4876.  
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882.  
  4883.  
  4884.  
  4885.  
  4886.  
  4887.  
  4888.  
  4889.  
  4890.  
  4891.  
  4892.  
  4893.  
  4894.  
  4895.  
  4896.  
  4897.  
  4898.  
  4899.  
  4900.  
  4901.  
  4902.  
  4903.  
  4904.  
  4905.  
  4906.  
  4907.  
  4908.  
  4909.  
  4910.  
  4911.  
  4912.  
  4913.  
  4914.  
  4915.  
  4916.  
  4917.  
  4918.  
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.  
  4925.  
  4926.  
  4927.  
  4928.  
  4929.  
  4930. > 3.8.1  Incomplete Type Declarations
  4931.  
  4932.  
  4933. There are no particular limitations on the designated type   of  an  access
  4934. type.  In particular, the type of a component of the designated type can be
  4935. another  access  type, or even the same access type.  This permits mutually
  4936. dependent and recursive access types.  Their declarations require  a  prior
  4937. incomplete (or private) type declaration for one or more types.
  4938.  
  4939.     incomplete_type_declaration ::= type identifier [discriminant_part];
  4940.  
  4941. For  each  incomplete  type  declaration,  there  must  be  a corresponding
  4942. declaration  of  a  type  with  the  same  identifier.   The  corresponding
  4943. declaration  must be either a full type declaration or the declaration of a
  4944. task type.  In the rest of this section, explanations are given in terms of
  4945. full type declarations;  the same rules apply also to declarations of  task
  4946. types.  If the incomplete type declaration occurs immediately within either
  4947. a declarative part or the visible part of a package specification, then the
  4948. full  type  declaration  must  occur  later  and  immediately  within  this
  4949. declarative part or visible  part.   If  the  incomplete  type  declaration
  4950. occurs immediately within the private part of a package, then the full type
  4951. declaration must occur later and immediately within either the private part
  4952. itself, or the declarative part of the corresponding package body.
  4953.  
  4954. A  discriminant part must be given in the full type declaration if and only
  4955. if one is given in the incomplete type declaration;  if discriminant  parts
  4956. are  given,  then  they must conform (see 6.3.1 for the conformance rules).
  4957. Prior to the end of the full type declaration, the only allowed  use  of  a
  4958. name  that  denotes a type declared by an incomplete type declaration is as
  4959. the type mark in the subtype indication of an access type definition;   the
  4960. only   form   of  constraint  allowed  in  this  subtype  indication  is  a
  4961. discriminant constraint.
  4962.  
  4963. The elaboration of an incomplete type declaration creates a type.   If  the
  4964. incomplete  type  declaration  has  a  discriminant  part, this elaboration
  4965. includes that of the discriminant part:  in such a case,  the  discriminant
  4966. part of the full type declaration is not elaborated.
  4967.  
  4968. Example of a recursive type:
  4969.  
  4970.     type CELL;  --  incomplete type declaration
  4971.     type LINK is access CELL;
  4972.  
  4973.     type CELL is
  4974.        record
  4975.           VALUE : INTEGER;
  4976.           SUCC  : LINK;
  4977.           PRED  : LINK;
  4978.        end record;
  4979.  
  4980.     HEAD : LINK := new CELL'(0, null, null);
  4981.     NEXT : LINK := HEAD.SUCC;
  4982.  
  4983. Examples of mutually dependent access types:
  4984.  
  4985.     type PERSON(SEX : GENDER);  --  incomplete type declaration
  4986.     type CAR;                   --  incomplete type declaration
  4987.  
  4988.     type PERSON_NAME is access PERSON;
  4989.     type CAR_NAME    is access CAR;
  4990.  
  4991.     type CAR is
  4992.        record
  4993.           NUMBER : INTEGER;
  4994.           OWNER  : PERSON_NAME;
  4995.        end record;
  4996.  
  4997.     type PERSON(SEX : GENDER) is
  4998.        record
  4999.           NAME    : STRING(1 .. 20);
  5000.           BIRTH   : DATE;
  5001.           AGE     : INTEGER range 0 .. 130;
  5002.           VEHICLE : CAR_NAME;
  5003.           case SEX is
  5004.              when M => WIFE    : PERSON_NAME(SEX => F);
  5005.              when F => HUSBAND : PERSON_NAME(SEX => M);
  5006.           end case;
  5007.        end record;
  5008.  
  5009.     MY_CAR, YOUR_CAR, NEXT_CAR : CAR_NAME;  --  implicitly initialized with null value
  5010.  
  5011. References:   access  type  3.8, access type definition 3.8, component 3.3,
  5012. conform 6.3.1, constraint  3.3,  declaration  3.1,  declarative  item  3.9,
  5013. designate  3.8,  discriminant  constraint  3.7.2,  discriminant part 3.7.1,
  5014. elaboration 3.9, identifier 2.3, name 4.1, subtype indication  3.3.2,  type
  5015. 3.3, type mark 3.3.2
  5016.  
  5017.  
  5018.  
  5019. > 3.8.2  Operations of Access Types
  5020.  
  5021.  
  5022. The  basic  operations of an access type include the operations involved in
  5023. assignment,   allocators   for   the   access   type,   membership   tests,
  5024. qualification,   explicit   conversion,  and  the  literal  null.   If  the
  5025. designated type is a type with discriminants, the basic operations  include
  5026. the  selection  of the corresponding discriminants;  if the designated type
  5027. is  a  record  type,  they  include  the  selection  of  the  corresponding
  5028. components;   if  the  designated  type  is an array type, they include the
  5029. formation of indexed components and slices;  if the designated  type  is  a
  5030. task   type,   they  include  selection  of  entries  and  entry  families.
  5031. Furthermore, the basic operations  include  the  formation  of  a  selected
  5032. component with the reserved word all (see 4.1.3).
  5033.  
  5034. If  the  designated type is an array type, the basic operations include the
  5035. attributes that have the attribute  designators  FIRST,  LAST,  RANGE,  and
  5036. LENGTH  (likewise,  the  attribute designators of the N-th dimension).  The
  5037. prefix of each of these attributes must be a  value  of  the  access  type.
  5038. These  attributes yield the corresponding characteristics of the designated
  5039. object (see 3.6.2).
  5040.  
  5041. If the designated type is a task type, the  basic  operations  include  the
  5042. attributes that have the attribute designators TERMINATED and CALLABLE (see
  5043. 9.9).  The prefix of each of these attributes must be a value of the access
  5044. type.   These  attributes  yield  the  corresponding characteristics of the
  5045. designated task objects.
  5046.  
  5047. In addition, the  attribute  T'BASE  (see  3.3.3)  and  the  representation
  5048. attributes T'SIZE and T'STORAGE_SIZE (see 13.7.2) are defined for an access
  5049. type  or subtype T;  the attributes A'SIZE and A'ADDRESS are defined for an
  5050. access object A (see 13.7.2).
  5051.  
  5052.  
  5053.  
  5054.  
  5055.  
  5056.  
  5057.  
  5058.  
  5059.  
  5060.  
  5061.  
  5062. Besides the basic operations, the operations of an access type include  the
  5063. predefined comparison for equality and inequality.
  5064.  
  5065. References:   access  type  3.8,  allocator 4.8, array type 3.6, assignment
  5066. 5.2, attribute 4.1.4, attribute designator  4.1.4,  base  type  3.3,  basic
  5067. operation  3.3.3, collection 3.8, constrained array subtype 3.6, conversion
  5068. 4.6,  designate  3.8,  designated  subtype  3.8,   designated   type   3.8,
  5069. discriminant 3.3, indexed component 4.1.1, literal 4.2, membership test 4.5
  5070. 4.5.2,  object 3.2.1, operation 3.3, private type 7.4, qualified expression
  5071. 4.7, record type 3.7, selected component 4.1.3, slice 4.1.2,  subtype  3.3,
  5072. task type 9.1, type 3.3
  5073.  
  5074.  
  5075.  
  5076.  
  5077.  
  5078.  
  5079.  
  5080.  
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086.  
  5087.  
  5088.  
  5089.  
  5090.  
  5091.  
  5092.  
  5093.  
  5094.  
  5095.  
  5096.  
  5097.  
  5098.  
  5099.  
  5100.  
  5101.  
  5102.  
  5103.  
  5104.  
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110.  
  5111.  
  5112.  
  5113.  
  5114.  
  5115.  
  5116.  
  5117.  
  5118.  
  5119.  
  5120.  
  5121.  
  5122.  
  5123.  
  5124.  
  5125.  
  5126.  
  5127. > 3.9  Declarative Parts
  5128.  
  5129.  
  5130. A declarative part contains declarative items (possibly none).
  5131.  
  5132.     declarative_part ::=
  5133.        {basic_declarative_item} {later_declarative_item}
  5134.  
  5135.     basic_declarative_item ::= basic_declaration
  5136.        | representation_clause | use_clause
  5137.  
  5138.     later_declarative_item ::= body
  5139.        | subprogram_declaration | package_declaration
  5140.        | task_declaration       | generic_declaration
  5141.        | use_clause             | generic_instantiation
  5142.  
  5143.     body ::= proper_body | body_stub
  5144.  
  5145.     proper_body ::= subprogram_body | package_body | task_body
  5146.  
  5147. The  elaboration  of  a declarative part consists of the elaboration of the
  5148. declarative items, if any, in the order in which  they  are  given  in  the
  5149. declarative  part.  After its elaboration, a declarative item is said to be
  5150. elaborated.  Prior to the completion of its elaboration  (including  before
  5151. the elaboration), the declarative item is not yet elaborated.
  5152.  
  5153. For  several  forms  of declarative item, the language rules (in particular
  5154. scope and visibility rules) are  such  that  it  is  either  impossible  or
  5155. illegal  to  use  an  entity before the elaboration of the declarative item
  5156. that declares this entity.  For example, it is not possible to use the name
  5157. of a type for an object declaration if the corresponding  type  declaration
  5158. is  not  yet  elaborated.   In the case of bodies, the following checks are
  5159. performed:
  5160.  
  5161.   -  For a subprogram call, a check is made that the body of the subprogram
  5162.      is already elaborated.
  5163.  
  5164.   -  For the activation of a task, a check is made that  the  body  of  the
  5165.      corresponding task unit is already elaborated.
  5166.  
  5167.   -  For the instantiation of a generic unit that has a body,  a  check  is
  5168.      made that this body is already elaborated.
  5169.  
  5170. The exception PROGRAM_ERROR is raised if any of these checks fails.
  5171.  
  5172. If  a subprogram declaration, a package declaration, a task declaration, or
  5173. a generic declaration is a declarative item of a  given  declarative  part,
  5174. then  the  body  (if  there  is  one)  of  the program unit declared by the
  5175. declarative item must itself be a declarative item of this declarative part
  5176. (and must appear later).  If the body is a body  stub,  then  a  separately
  5177. compiled  subunit  containing the corresponding proper body is required for
  5178. the program unit (see 10.2).
  5179.  
  5180. References:  activation 9.3, instantiation  12.3,  program_error  exception
  5181. 11.1, scope 8.2, subprogram call 6.4, type 3.3, visibility 8.3
  5182.  
  5183.  
  5184.  
  5185.  
  5186.  
  5187.  
  5188.  
  5189.  
  5190.  
  5191.  
  5192. Elaboration  of  declarations:   3.1,  component  declaration 3.7, deferred
  5193. constant  declaration  7.4.3,  discriminant  specification   3.7.1,   entry
  5194. declaration   9.5,   enumeration   literal   specification  3.5.1,  generic
  5195. declaration 12.1, generic instantiation 12.3, incomplete  type  declaration
  5196. 3.8.1,  loop  parameter specification 5.5, number declaration 3.2.2, object
  5197. declaration 3.2.1, package declaration 7.2,  parameter  specification  6.1,
  5198. private  type  declaration  7.4.1,  renaming  declaration  8.5,  subprogram
  5199. declaration 6.1, subtype declaration  3.3.2,  task  declaration  9.1,  type
  5200. declaration 3.3.1
  5201.  
  5202.  
  5203.  
  5204.  
  5205.  
  5206.  
  5207.  
  5208.  
  5209.  
  5210.  
  5211.  
  5212.  
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218.  
  5219.  
  5220.  
  5221.  
  5222.  
  5223.  
  5224.  
  5225.  
  5226.  
  5227.  
  5228.  
  5229.  
  5230.  
  5231.  
  5232.  
  5233.  
  5234.  
  5235.  
  5236.  
  5237.  
  5238.  
  5239.  
  5240.  
  5241.  
  5242.  
  5243.  
  5244.  
  5245.  
  5246.  
  5247.  
  5248.  
  5249.  
  5250.  
  5251.  
  5252.  
  5253.  
  5254.  
  5255.  
  5256.  
  5257. Elaboration  of type definitions:  3.3.1, access type definition 3.8, array
  5258. type  definition  3.6,  derived  type  definition  3.4,  enumeration   type
  5259. definition  3.5.1,  integer  type  definition  3.5.4,  real type definition
  5260. 3.5.6, record type definition 3.7
  5261.  
  5262. Elaboration of other constructs:  context  clause  10.1,  body  stub  10.2,
  5263. compilation  unit 10.1, discriminant part 3.7.1, generic body 12.2, generic
  5264. formal  parameter  12.1  12.3,  library  unit  10.5,  package   body   7.1,
  5265. representation  clause  13.1,  subprogram body 6.3, subunit 10.2, task body
  5266. 9.1, task object 9.2, task specification 9.1, use clause 8.4,  with  clause
  5267. 10.1.1
  5268.  
  5269.  
  5270.  
  5271.  
  5272.  
  5273.  
  5274.  
  5275.  
  5276.  
  5277.  
  5278.  
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284.  
  5285.  
  5286.  
  5287.  
  5288.  
  5289.  
  5290.  
  5291.  
  5292.  
  5293.  
  5294.  
  5295.  
  5296.  
  5297.  
  5298.  
  5299.  
  5300.  
  5301.  
  5302.  
  5303.  
  5304.  
  5305.  
  5306.  
  5307.  
  5308.  
  5309.  
  5310.  
  5311.  
  5312.  
  5313.  
  5314.  
  5315.  
  5316.  
  5317.  
  5318.